PHP½ø³ÌÖ®¼ä¹²Ïí±äÁ¿ÁíÒ»ÖÖ°ì·¨
ÕâÁ½Ì׺¯ÊýµÄʹÓÃÏ൱¼òµ¥£¬ÏÂÃæ·Ö±ð¸ø³ö¼òµ¥µÄÓ÷¨£¬¸üÏêϸµÄÐÅÏ¢¿ÉÒԲο¼phpÊֲᡣ
Ò»¡¢System VµÄ¹²ÏíÄÚ´æʹÓãº
<?php // ´´½¨ÄÚ´æ¿é $key = 12345; // ¹²ÏíÄÚ´æµÄkey£¬×¢£ºÀàÐÍΪint $memsize = 100; // ¹²ÏíÄÚ´æµÄ´óС£¬µ¥Î»byte $perm = 0666; // ¹²ÏíÄÚ´æ·ÃÎÊȨÏÞ£¬²Î¿¼linuxµÄȨÏÞ $var_key = 345; // ¹²ÏíÄÚ´æµÄij±äÁ¿µÄkey£¬×¢£ºÀàÐÍΪint $shmid = shm_attach( $key, $memsize, $perm ); // ´´½¨Ò»¸ö¹²ÏíÄÚ´æ shm_put_var( $shmid, $var_key, "abc" ); // ²åÈëÒ»¸ö¹²ÏíÄÚ´æ±äÁ¿£¬keyΪ$var_key£¬ÖµÎª"abc" shm_detach( $shmid ); // ¹Ø±Õ¹²ÏíÄÚ´æ ?>
ÔËÐÐÉÏÃæµÄphp³ÌÐò¿ÉÒÔ´´½¨Ò»¸ökeyΪ12345µÄ¹²ÏíÄڴ棬´óСΪ100×Ö½Ú£¬ÀïÃæÓиöֵΪ¡°abc¡±µÄ±äÁ¿¡£ÔÚlinuxÃüÁîÐÐÇÃÈëipcs¿ÉÒÔ¿´µ½´´½¨µÄ¹²ÏíÄÚ´æÐÅÏ¢£º
<?php // ¶ÁÈ¡ÄÚ´æ¿éÄÚÈÝ $shmid = shm_attach( 12345 ); // ·ÃÎÊkeyΪ12345µÄ¹²ÏíÄÚ´æ echo shm_get_var( $shmid, 345 ); // °Ñ¹²ÏíÄÚ´æÖÐkeyΪ345µÄ±äÁ¿´òÓ¡³öÀ´£¬ÕâÀォÏÔʾabc shm_remove( $shmid ); // ɾ³ý¸Ã¹²ÏíÄÚ´æ ?>
¶þ¡¢shmopµÄ¹²ÏíÄÚ´æʹÓãº
<?php // ´´½¨ÄÚ´æ¿é $key = 12345; // ¹²ÏíÄÚ´æµÄkey $memsize = 100; // ¹²ÏíÄÚ´æµÄ´óС£¬µ¥Î»byte $perm = 0666; // ¹²ÏíÄÚ´æ·ÃÎÊȨÏÞ£¬²Î¿¼linuxµÄȨÏÞ $offset = 0; // ¹²ÏíÄÚ´æÆ«ÒƵØÖ·£¬0±íʾ¹²ÏíÄÚ´æµÄÆðʼµØÖ· $shmid = shmop_open($key, "c", $perm, $memsize); // ´´½¨Ò»¸ö¹²ÏíÄڴ棬µÚ¶þ¸ö²ÎÊýc±íʾ´´½¨ $shm_bytes_written = shmop_write($shm_id, "abc", 0); // °Ñ"abc"дÈë¹²ÏíÄÚ´æ echo $shm_bytes_written; // ´òÓ¡³öдÈë¹²ÏíÄÚ´æµÄÊý¾Ý³¤¶È£¬ÕâÀォÏÔʾ3 shmop_close($shm_id); // ¹Ø±Õ¹²ÏíÄÚ´æ ?>
ÔËÐÐÕâ¸öphp½«´´½¨Ò»¸ökeyΪ12345£¬´óСΪ100×ֽڵĹ²ÏíÄڴ棬ÀïÃæдÈëÁË¡±abc¡±Õâ¸ö×Ö·û´®¡£ÎÒÃÇÔÚдһ¸ö·ÃÎÊÕâ¸ö¹²ÏíÄÚ´æµÄphp£º
<?php // ¶ÁÈ¡ÄÚ´æ¿é $shm_id = shmop_open(12345, "w", 0, 0); // ´ò¿ªkeyΪ12345µÄ¹²ÏíÄڴ棬µÚ¶þ¸ö²ÎÊýw±íʾÒÔ¶Áд·½Ê½´ò¿ª£¬´ò¿ªÒÑ´æÔڵĹ²ÏíÄڴ棬µÚÈý¸öºÍµÚËĸö²ÎÊý±ØÐëÊÇ0 $shm_data = shmop_read($shm_id, 0, 3); // ´Ó¹²ÏíÄÚ´æÀïÃæ¶ÁÈ¡3×Ö½ÚµÄÊý¾Ý£¬µÚ¶þ¸ö²ÎÊýÊÇÆ«ÒƵØÖ·£¬0±íʾ¹²ÏíÄÚ´æµÄÆðʼµØÖ· echo $shm_data; // ´òÓ¡³öÉϸöº¯Êý·µ»ØµÄ¹²ÏíÄÚ´æÊý¾Ý shmop_delete($shm_id); // ɾ³ý¹²ÏíÄÚ´æ ?>
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- php³£ÓÃÕýÔò±í´ïʽ
- phpÐÔÄܼà²âÄ£¿éXHProf
- ÈÃCI¿ò¼ÜÖ§³Öservice²ã
- ʹÓÃPHPÉú³É´øLOGOµÄ¸öÐÔ»¯¶þάÂëͼÏñ
- ¹ØÓÚCodeIgniterÄã¿ÉÄܲ»ÖªµÀµÄ5¸ö֪ʶµã
- Memcache ºÁÃ뼶³¬Ê±¼°ÆäËû³£¼ûÎÊÌâ»ã×Ü
- [PHP±Ê¼Ç]PHPQueryÒ»¸ö´¦ÀíDOMµÄÀûÆ÷
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- PHP»ñÈ¡Óû§µÄÕæʵIP£¬²¢ÅжÏÊÇ·ñÄÚÍøIP
- PHP ´íÎóÈÕÖ¾ error_log
- ÀûÓÃbigpipe»úÖÆʵÏÖÒ³ÃæÄ£¿éµÄÒì²½äÖȾ chunked¼¼Êõ
- php¿ØÖÆÎļþÏÂÔØËÙ¶È
- js + php ¶ÁÈ¡¡¢²¥·ÅÊÓƵÁ÷ ¼æÈÝfirefox£¬c....
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- UNICODE Óë UTF-8 µÄ¹Øϵ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- phpʹÓÃmb_detect_encoding¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ