phpµ¼³öMemcachedËùÓлº´æÊý¾Ý
¹ØÓÚµ¼³ömemcachedµÄÈ«²¿Êý¾Ý£¬Ö»ÊÇʹÓÃÁËmemcachedÌṩµÄ¼¸¸ö¹¦ÄܽӿڶøÒÑ£¬¾ßÌå´úÂëÈçÏ£¬µ«ÊÇÓм¸¸öҪעÒâµÄµØ·½¡£
- µÚÒ»¸öÊÇcachedumpÃüÁîÿ´Î·µ»ØµÄÊý¾Ý´óСֻÓÐ2M£¬Õâ¸öÊÇmemcachedµÄ´úÂëÖÐдËÀµÄÒ»¸öÊýÖµ£¬³ý·ÇÔÚ±àÒëÇ°ÐÞ¸Ä
- µÚ¶þ¸öÎÊÌâÊÇÔÚÒ»¸ömemcached×öcachedumpʱ£¬Ëƺõ²»ÄÜÔÚÑ»·ÀïÃæ¶ÔÁíÍâÒ»¸ömemcached×öset²Ù×÷¡£Õâ¸öÖ»ÊÇÔÚ³¢ÊÔµÄʱºò·¢ÏÖµÄÎÊÌ⣬һ¿ªÊ¼ÎÒÊÇÔÚµÚÒ»¸öforeachÑ»·ÖлñÈ¡Êý¾Ý²¢·Åµ½ÁíÍâÒ»¸ömemcachedÀïµÄ£¬Õâ¸öʱºò»á³öÏÖ·ÅÖõÄÊý¾ÝΪ2byteµÄÒ»¸ö¼ÙÊý¾Ý¡£¾¹ý²âÊÔ£¬È¡µÄÊý¾Ýʱ¶ÔµÄ£¬µ«ÊǷŵÄʱºò³öÏÖÁË´íÎó£¬ËùÒÔÏÂÃæµÄ´úÂëÏÈÑ»·cachedumpµÄkey£¬ÔÙµ¥¶ÀÑ»·keyÁбíÈ¥µ¼³öÊý¾Ý¡£
- ×îºóÕâ¸öÎÊÌâÊÇÓеÚÒ»¸öÒýÆðµÄ£¬¸ù¾ÝÎÒµ¼ÈëµÄÇé¿ö¿´£¬2MÒ»°ãÖ»ÄÜÄõ½4Íò×óÓÒµÄkey£¬ÓÐЩslabµÄitem´ïµ½ÁË4ǧÍò£¬4ÍòÖ»ÊÇǧ·ÖÖ®Ò»£¬ËùÒÔÖ»Äܱߵ¼³ö±ßɾ³ý£¬ÖªµÀûÓÐÊý¾Ý¿ÉÒÔµ¼³öΪֹ¡£
<?php echo "Start time ".date("Y-m-d H:i:s")."\n"; $slabs = array_slice($argv, 1); foreach ($slabs as $slabId) { export($slabId); } echo "End time ".date("Y-m-d H:i:s")."\n"; function export($slabId) { $num = 0; $total = 0; $times = 0; $deleteCount = 0; $addCount = 0; $fromCache = new Memcache(); $fromCache->connect("192.168.0.100", 11211); for ($i = 0; $i < 200; $i++) { $keys = array(); $cdump = $fromCache->getExtendedStats( 'cachedump' , intval( $slabId ) , 10000000 ); foreach( $cdump AS $entries ) { if( $entries ) { foreach( $entries AS $eName => $eData ) { $keys[] = $eName; } } } $toCache = new Memcache(); $toCache->connect("192.168.0.101", 11211); if (count($keys) == 0 ) { break; } foreach ($keys as $key) { $value = $fromCache->get($key); if ($toCache->add($key, $value, MEMCACHE_COMPRESSED, 864000)) { $back = $toCache->get($key); if (strlen(serialize($value)) != strlen(serialize($back))) { $toCache->delete($key); } else { $num++; } } $fromCache->delete($key); } $deleteCount += count($keys); $addCount += $num; $num = 0; } echo "Total import $addCount items into slab $slabId.\n"; echo "Total remove $deleteCount items from $slabId.\n"; } ?>
²Î¿¼Á´½Ó£º
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿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¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ