﻿{"id":842,"date":"2012-05-28T17:14:36","date_gmt":"2012-05-28T09:14:36","guid":{"rendered":"http:\/\/nick.workao.org\/?p=842"},"modified":"2012-05-30T16:20:11","modified_gmt":"2012-05-30T08:20:11","slug":"%e7%bb%99php%e5%8a%a0%e9%80%9f%ef%bc%8ceaccelerator%e9%85%8d%e7%bd%ae%e5%92%8c%e4%bd%bf%e7%94%a8%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"http:\/\/nick.txtcc.com\/index.php\/linux\/842","title":{"rendered":"\u7ed9PHP\u52a0\u901f\uff0ceAccelerator\u914d\u7f6e\u548c\u4f7f\u7528\u6307\u5357"},"content":{"rendered":"<p>Trackback URL:\u00a0<a href=\"http:\/\/www.toplee.com\/blog\/wp-trackback.php?p=100\"><a href=\"http:\/\/www.toplee.com\/blog\/wp-trackback.php?p=100\">http:\/\/www.toplee.com\/blog\/wp-trackback.php?p=100<\/a><\/a><\/p>\n<p>\u524d\u4e00\u6bb5\u65f6\u95f4\u5b8c\u6210\u4e86\u670d\u52a1\u5668\u4eceFreeBSD4.10\u52306.1\u7684\u5347\u7ea7\uff0c\u540c\u65f6\u628aPHP\u4e5f\u5347\u7ea7\u5230\u4e86\u6700\u65b0\u7684PHP5.1.4\uff0cApache\u4e5f\u5347\u7ea7\u5230\u4e86\u6700\u65b0\u7684Apache2.2\uff0c\u4e3a\u4e86\u66f4\u597d\u7684\u63d0\u9ad8\u7cfb\u7edf\u7684\u6027\u80fd\uff0c\u8003\u8651\u5bf9PHP\u518d\u8fdb\u884c\u4e00\u4e9b\u4f18\u5316\uff0c\u524d\u4e24\u5e74\u63a5\u89e6\u8fc7MMCache\u548ceAccelerator\uff0c\u5c24\u5176\u5bf9eAccelerator\u975e\u5e38\u559c\u6b22\uff0c\u8fd9\u6b21\u4f18\u5316\u4e5f\u9009\u62e9\u4e86\u5b83\uff0c\u4e0b\u9762\u6574\u7406\u4e00\u4e9b\u6587\u6863\u548c\u5927\u5bb6\u5206\u4eab\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u76ee\u5f55\uff1a\n\u4e00\u3001eAccelerator\u4ecb\u7ecd\n1\u3001\u80cc\u666f\n2\u3001\u539f\u7406\n\u4e8c\u3001\u5b89\u88c5\u548c\u914d\u7f6e\n1\u3001\u652f\u6301\u5e73\u53f0\n2\u3001\u7cfb\u7edf\u8981\u6c42\n3\u3001\u5b89\u88c5\n4\u3001php.ini\u6587\u4ef6\u914d\u7f6e\n5\u3001\u9a8c\u8bc1\u5b89\u88c5\n\u4e09\u3001\u4f7f\u7528eAccelerator\u5f00\u53d1PHP\u4ee3\u7801\n1\u3001API\u6587\u6863\u548c\u63a5\u53e3\u8bf4\u660e\n2\u3001\u5f00\u53d1\u8303\u4f8b\n\u56db\u3001\u9644\u5f55\u548c\u53c2\u8003\u8d44\u6599<\/p>\n<p>\u4e00\u3001eAccelerator\u4ecb\u7ecd<\/p>\n<p>1\u3001\u80cc\u666f\neAccelerator \u662f\u4e00\u4e2a\u514d\u8d39\u5f00\u6e90\u7684PHP\u52a0\u901f\u3001\u4f18\u5316\u3001\u7f16\u8bd1\u548c\u52a8\u6001\u7f13\u5b58\u7684\u9879\u76ee\uff0c\u5b83\u53ef\u4ee5\u901a\u8fc7\u7f13\u5b58PHP\u4ee3\u7801\u7f16\u8bd1\u540e\u7684\u7ed3\u679c\u6765\u63d0\u9ad8PHP\u811a\u672c\u7684\u6027\u80fd\uff0c\u4f7f\u5f97\u4e00\u5411\u5f88\u590d\u6742\u548c\u79bb\u6211\u4eec\u5f88\u8fdc\u7684PHP\u811a\u672c\u7f16\u8bd1\u95ee\u9898\u5b8c\u5168\u5f97\u5230\u89e3\u51b3\u3002\u901a\u8fc7\u4f7f\u7528eAccelerator\uff0c\u53ef\u4ee5\u4f18\u5316\u4f60\u7684PHP\u4ee3\u7801\u6267\u884c\u901f\u5ea6\uff0c\u964d\u4f4e\u670d\u52a1\u5668\u8d1f\u8f7d\uff0c\u53ef\u4ee5\u63d0\u9ad8PHP\u5e94\u7528\u6267\u884c\u901f\u5ea6\u6700\u9ad8\u8fbe10\u500d\u3002<\/p>\n<p>eAccelerator \u9879\u76ee\u8bde\u751f\u4e8e2004\u5e74\uff0c\u5f53\u65f6\u5b83\u662f\u4f5c\u4e3a\u00a0<a href=\"http:\/\/sourceforge.net\/projects\/turck-mmcache\" target=\"_blank\">Turck MMCache\u00a0<\/a>\u9879\u76ee\u7684\u4e00\u4e2a\u5206\u652f\u63d0\u51fa\u5e76\u6295\u5165\u5f00\u53d1\u7684\u3002 Turck MMCache \u7531 Dmitry Stogov \u5f00\u53d1\uff0c\u662f\u4e2a\u975e\u5e38\u4f18\u79c0\u7684PHP\u5185\u5b58\u7f13\u5b58\u52a0\u901f\u7cfb\u7edf\uff0c\u5982\u4eca\u4ecd\u7136\u6709\u5f88\u5927\u90e8\u5206 eAccelerator \u7684\u4ee3\u7801\u5e94\u7528\u5230\u8be5\u9879\u76ee\u4e2d\uff0c\u76ee\u524d\u8be5\u9879\u76ee\u6709\u5f88\u957f\u65f6\u95f4\u6ca1\u6709\u66f4\u65b0\u4e86\uff0c\u5bf9\u4e8e\u6700\u65b0\u7684PHP5.x\u7684\u652f\u6301\u8fd8\u672a\u63a8\u51fa\u3002<\/p>\n<p>2\u3001\u539f\u7406\neAccelerator \u901a\u8fc7\u628a\u7ecf\u8fc7\u7f16\u8bd1\u540e\u7684PHP\u4ee3\u7801\u7f13\u5b58\u5230\u5171\u4eab\u5185\u5b58\u4e2d\uff0c\u5e76\u5728\u7528\u6237\u8bbf\u95ee\u7684\u65f6\u5019\u76f4\u63a5\u8c03\u7528\u4ece\u800c\u8d77\u5230\u9ad8\u6548\u7684\u52a0\u901f\u4f5c\u7528\u3002\u5b83\u7684\u6548\u7387\u975e\u5e38\u9ad8\uff0c\u4ece\u521b\u5efa\u5171\u4eab\u5185\u5b58\u5230\u67e5\u627e\u7f16\u8bd1\u540e\u7684\u4ee3\u7801\u90fd\u5728\u975e\u5e38\u77ed\u7684\u65f6\u95f4\u5185\u5b8c\u6210\uff0c\u5bf9\u4e8e\u4e0d\u80fd\u7f13\u5b58\u5230\u5171\u4eab\u5185\u5b58\u4e2d\u7684\u6587\u4ef6\u548c\u4ee3\u7801\uff0ceAccelerator\u8fd8\u53ef\u4ee5\u628a\u4ed6\u4eec\u7f13\u5b58\u5230\u7cfb\u7edf\u78c1\u76d8\u4e0a\u3002<\/p>\n<p>eAccelerator \u540c\u6837\u8fd8\u652f\u6301PHP\u4ee3\u7801\u7684\u7f16\u8bd1\u548c\u89e3\u91ca\u6267\u884c\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7encoder.php\u811a\u672c\u6765\u5bf9php\u4ee3\u7801\u8fdb\u884c\u7f16\u8bd1\u8fbe\u5230\u4fdd\u62a4\u4ee3\u7801\u7684\u76ee\u7684\uff0c\u7ecf\u8fc7\u7f16\u8bd1\u540e\u7684\u4ee3\u7801\u5fc5\u987b\u8fd0\u884c\u5728\u5b89\u88c5\u4e86eAccelerator\u7684\u73af\u5883\u4e0b\u3002eAccelerator\u7f16\u8bd1\u540e\u7684\u4ee3\u7801\u4e0d\u80fd\u88ab\u53cd\u7f16\u8bd1\uff0c\u5b83\u4e0d\u8c61\u5176\u4ed6\u4e00\u4e9b\u7f16\u8bd1\u5de5\u5177\u90a3\u6837\u53ef\u4ee5\u8fdb\u884c\u53cd\u7f16\u8bd1\uff0c\u8fd9\u5c06\u4f7f\u5f97\u4ee3\u7801\u66f4\u52a0\u5b89\u5168\u548c\u9ad8\u6548\u3002<\/p>\n<p>\u4e8c\u3001eAccelerator\u5b89\u88c5\u914d\u7f6e<\/p>\n<p>1\u3001\u652f\u6301\u5e73\u53f0\n\u7531\u4e8eaAccelerator\u63d0\u4f9b\u4e86\u5927\u90e8\u5206\u57fa\u4e8e\u5171\u4eab\u5185\u5b58\u7684API\uff0c\u6240\u4ee5\u5728<em>nix\u7684\u5e73\u53f0\u4e0a\u5c06\u5f97\u5230\u66f4\u597d\u7684\u652f\u6301\uff0c\u867d\u7136\u4e5f\u53d1\u5e03\u4e86\u57fa\u4e8ewindows\u5e73\u53f0\u7684binary\u7248\u672c\uff0c\u4f46\u6211\u5728\u8fd9\u91cc\u5c31\u53ea\u63d0\u4f9b\u57fa\u4e8e<\/em>nix\u5e73\u53f0\u7684\u914d\u7f6e\u548c\u8bf4\u660e\uff0c\u76ee\u524d\u53ef\u4ee5\u652f\u6301\u7684\u5e73\u53f0\u5305\u62ecLinux, FreeBSD, OpenBSD, Mac OS X, Solaris, AIX en HP-UX\u3002<\/p>\n<p>2\u3001\u7cfb\u7edf\u8981\u6c42\nphp4 or php5\nautoconf\nautomake\nlibtool\nm4\neAccelerator \u53ea\u652f\u6301\u4f7f\u7528 mod_php \u6216\u8005 fastcgi mode \u5b89\u88c5\u7684PHP<\/p>\n<p>3\u3001\u5b89\u88c5\n\u5148\u53bbeAccelerator\u5b98\u65b9\u4e0b\u8f7d\u6700\u65b0\u7248\u7684\u6e90\u7801\u5305\uff1a<a href=\"http:\/\/sourceforge.net\/projects\/eaccelerator\/files\/eaccelerator\/\"><a href=\"http:\/\/sourceforge.net\/projects\/eaccelerator\/files\/eaccelerator\/\">http:\/\/sourceforge.net\/projects\/eaccelerator\/files\/eaccelerator\/<\/a><\/a><\/p>\n<div>\n<div>#tar -zxvf .\/eaccelerator-0.9.5-beta2.tar.bz2\n#cd eaccelerator-0.9.5-beta2\n#export PHP_PREFIX=&#8221;\/usr\/local&#8221; \uff08\u628aPHP\u5b89\u88c5\u76ee\u5f55\u5bfc\u5165\u5230\u73af\u5883\u53d8\u91cf\uff0cFreeBSD\u9ed8\u8ba4\u662f\/usr\/local\uff09\n#$PHP_PREFIX\/bin\/phpize\n#.\/configure &#8211;enable-eaccelerator=shared &#8211;with-php-config=$PHP_PREFIX\/bin\/php-config\n#make\n#make install<\/div>\n<\/div>\n<p>4\u3001ini\u6587\u4ef6\u914d\u7f6e\n\u5b89\u88c5\u5b8c\u6210\uff0c\u4e0b\u9762\u5f00\u59cb\u914d\u7f6ephp.ini\u6587\u4ef6,eAccelerator\u63d0\u4f9b\u4e86\u4e24\u79cd\u914d\u7f6e\u548c\u8c03\u7528\u65b9\u5f0f\uff0c\u5206\u522b\u5982\u4e0b\u3002<\/p>\n<p>\u5b89\u88c5\u4e3a Zend extension \u6a21\u5f0f\uff1a<\/p>\n<div>\n<div>zend_extension=&#8221;\/usr\/local\/lib\/php\/20050922\/eaccelerator.so&#8221;\neaccelerator.shm_size=&#8221;16&#8243;\neaccelerator.cache_dir=&#8221;\/tmp\/eaccelerator&#8221;\neaccelerator.enable=&#8221;1&#8243;\neaccelerator.optimizer=&#8221;1&#8243;\neaccelerator.check_mtime=&#8221;1&#8243;\neaccelerator.debug=&#8221;0&#8243;\neaccelerator.log_file = &#8220;\/var\/log\/httpd\/eaccelerator_log&#8221;\neaccelerator.filter=&#8221;&#8221;\neaccelerator.shm_max=&#8221;0&#8243;\neaccelerator.shm_ttl=&#8221;0&#8243;\neaccelerator.shm_prune_period=&#8221;0&#8243;\neaccelerator.shm_only=&#8221;0&#8243;\neaccelerator.compress=&#8221;1&#8243;\neaccelerator.compress_level=&#8221;9&#8243;<\/div>\n<\/div>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u4e86thread safe\u6a21\u5f0f\u5b89\u88c5\u7684PHP\uff0c\u4f60\u5fc5\u987b\u4f7f\u7528 \u201czend_extension_ts\u201d \u66ff\u6362\u7b2c\u4e00\u884c\u7684 \u201czend_extension\u201d.<\/p>\n<p>\u5b89\u88c5\u4e3a PHP extension \u6a21\u5f0f\uff1a\uff08\u8fd9\u662f\u5927\u90e8\u5206\u91c7\u7528\u7684\u65b9\u5f0f\uff09<\/p>\n<div>\n<div>extension=&#8221;eaccelerator.so&#8221;\neaccelerator.shm_size=&#8221;16&#8243;\neaccelerator.cache_dir=&#8221;\/tmp\/eaccelerator&#8221;\neaccelerator.enable=&#8221;1&#8243;\neaccelerator.optimizer=&#8221;1&#8243;\neaccelerator.check_mtime=&#8221;1&#8243;\neaccelerator.debug=&#8221;0&#8243;\neaccelerator.log_file = &#8220;\/var\/log\/httpd\/eaccelerator_log&#8221;\neaccelerator.filter=&#8221;&#8221;\neaccelerator.shm_max=&#8221;0&#8243;\neaccelerator.shm_ttl=&#8221;0&#8243;\neaccelerator.shm_prune_period=&#8221;0&#8243;\neaccelerator.shm_only=&#8221;0&#8243;\neaccelerator.compress=&#8221;1&#8243;\neaccelerator.compress_level=&#8221;9&#8243;<\/div>\n<\/div>\n<p>\u6709\u5173php.ini\u6587\u4ef6\u7684\u8be6\u7ec6\u914d\u7f6e\u8bf4\u660e\uff0c\u8bf7\u53c2\u7167\u6e90\u7801\u76ee\u5f55\u7684README\u6587\u6863\u6216\u8005\u8bbf\u95ee\u5b98\u65b9\u6587\u6863\uff1a<a href=\"http:\/\/eaccelerator.net\/wiki\/Settings\" target=\"_blank\">ini setting<\/a><\/p>\n<p>\u5b8c\u6210\u5b89\u88c5\u914d\u7f6e\u540e\uff0c\u6211\u4eec\u6700\u540e\u8981\u521b\u5efa\u7f13\u5b58\u76ee\u5f55<\/p>\n<div>\n<div>#mkdir \/tmp\/eaccelerator\n#chmod 777 \/tmp\/eaccelerator<\/div>\n<\/div>\n<p>5\u3001\u9a8c\u8bc1\u5b89\u88c5\u7ed3\u679c\n\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u60a8\u7684phpinfo()\u9875\u9762\u6216\u8005\u8fd0\u884c php -i \u5f97\u5230php\u914d\u7f6e\u4fe1\u606f\uff0c\u91cc\u9762\u5982\u679c\u770b\u5230\u7c7b\u4f3c\u4e0b\u9762\u7684\u4fe1\u606f\u5c31\u8868\u793a\u5b89\u88c5\u6210\u529f\u4e86\u3002<\/p>\n<div>\n<div>This program makes use of the Zend Scripting Language Engine:\nZend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies\nwith eAccelerator v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator<\/div>\n<\/div>\n<p>\u6211\u7684\u673a\u5668\u4e0a\u540c\u65f6\u8fd8\u5b89\u88c5\u4e86Zend Optimizer3.0.1\uff0c\u6240\u4ee5\u770b\u5230\u7684\u4fe1\u606f\u5982\u4e0b\uff1a<\/p>\n<div>\n<div>This program makes use of the Zend Scripting Language Engine:\nZend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies\nwith eAccelerator v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator\nwith Zend Extension Manager v1.0.10, Copyright (c) 2003-2006, by Zend Technologies\nwith Zend Optimizer v3.0.1, Copyright (c) 1998-2006, by Zend Technologies<\/div>\n<\/div>\n<p>\u5982\u679c\u4f60\u6253\u5f00\u4e86eAccelerator\u7684debug\u9009\u9879\uff0c\u53ef\u4ee5\u4ece\u65e5\u5fd7\u4e2d\u770b\u5230\u7c7b\u4f3c\u4e0b\u9762\u7684\u4fe1\u606f<\/p>\n<div>\n<div>#tail \/var\/log\/httpd\/eAccelerator_log\nEACCELERATOR hit: &#8220;\/var\/www\/toplee.com\/blog\/index.php&#8221;\nEACCELERATOR hit: &#8220;\/var\/www\/toplee.com\/blog\/wp-blog-header.php&#8221;\nEACCELERATOR hit: &#8220;\/var\/www\/toplee.com\/blog\/wp-config.php&#8221;\nEACCELERATOR hit: &#8220;\/var\/www\/toplee.com\/blog\/wp-settings.php&#8221;\nEACCELERATOR hit: &#8220;\/var\/www\/toplee.com\/blog\/wp-content\/plugins\/wp-cache\/wp-cache-phase1.php&#8221;\n&#8230;<\/div>\n<\/div>\n<p>\u4ee5\u4e0a\u4fe1\u606f\u8868\u793a\u6587\u4ef6\u90fd\u5f97\u5230\u4e86\u7f13\u5b58\u548c\u547d\u4e2d\u3002<\/p>\n<p>\u81f3\u6b64\uff0c\u6211\u4eec\u5c31\u5b8c\u6210\u4e86\u5168\u90e8\u7684\u5b89\u88c5\u548c\u914d\u7f6e\uff0c\u597d\u597d\u4eab\u53d7eAccelerator\u5e26\u7ed9\u4f60\u7684\u60ca\u559c\u5427\uff0c\u6839\u636eMichael\u7684\u6d4b\u8bd5\uff0c\u6548\u679c\u7684\u786e\u76f8\u5f53\u7684\u597d\u3002<\/p>\n<p>\u4e09\u3001\u5728PHP\u4e2d\u53ef\u4ee5\u4f7f\u7528eAccelerator\u7684API\u5f00\u53d1<\/p>\n<p>1\u3001API\u548c\u6587\u6863\u8bf4\u660e\uff1a<\/p>\n<p>eAccelerator\u63d0\u4f9b\u4e86\u4fbf\u6377\u4fbf\u6377\u800c\u53c8\u7a33\u5b9a\u7684\u672c\u673a\u7f13\u5b58\u5b9e\u73b0\u65b9\u5f0f\uff0c\u7531\u4e8e\u5927\u90e8\u5206\u4ee3\u7801\u5b9e\u73b0\u57fa\u4e8e\u5171\u4eab\u5185\u5b58\uff0c\u6240\u4ee5\u53ea\u80fd\u5728*nix\u5e73\u53f0\u4e2d\u4f7f\u7528\uff0cWindows\u5e73\u53f0Michael\u5c31\u6682\u65f6\u4e0d\u77e5\u9053\u4f55\u65f6\u6709\u8fd9\u65b9\u9762\u7684\u652f\u6301\u4e86\u3002\neAccelerator\u63d0\u4f9b\u5982\u4e0b\u7684API\u63a5\u53e3\u548c\u6587\u4ef6\uff1a\uff08\u4e0b\u8ff0\u6587\u4ef6\u5747\u5728\u6e90\u7801\u5305\u7684doc\/php\/\u76ee\u5f55\u4e0b\uff09<\/p>\n<p>\u6587\u4ef6\u5217\u8868\uff1a<\/p>\n<div>\n<div>cache.php\ndasm.php\nencoder.php\ninfo.php\nloader.php\nsession.php\nshared_memory.php<\/div>\n<\/div>\n<p>\u63a5\u53e3\u5217\u8868\uff1a<\/p>\n<div>\n<div>array eaccelerator_cached_scripts ()\nvoid eaccelerator_cache_output (string $key, string $eval_code, [int $ttl = 0])\nvoid eaccelerator_cache_page (string $key, [int $ttl = 0])\nvoid eaccelerator_cache_result (string $key, string $code, [int $ttl = 0])\nvoid eaccelerator_caching (boolean $flag)\nvoid eaccelerator_clean ()\nvoid eaccelerator_clear ()\narray eaccelerator_dasm_file (mixed $filename)\nmixed eaccelerator_encode (mixed $src, [mixed $prefix = &#8221;], [string $pre_content = &#8221;], [string $post_content = &#8221;])\nvoid eaccelerator_gc ()\nmixed eaccelerator_get (string $key)\narray eaccelerator_info ()\narray eaccelerator_list_keys ()\nvoid eaccelerator_load ()\nboolean eaccelerator_lock (string $key)\nvoid eaccelerator_optimizer (boolean $flag)\nvoid eaccelerator_purge ()\nboolean eaccelerator_put (string $key, mixed $value, [int $ttl = 0])\narray eaccelerator_removed_scripts ()\nboolean eaccelerator_rm (string $key)\nvoid eaccelerator_rm_page (string $key)\nboolean eaccelerator_set_session_handlers ()\nboolean eaccelerator_unlock (string $key)<\/div>\n<\/div>\n<p>\u6709\u5173\u4e0a\u8ff0\u6587\u6863\u8be6\u7ec6\u8bf4\u660e\u8bf7\u53c2\u8003\u5b98\u65b9\u6587\u6863\uff1a<a href=\"http:\/\/bart.eaccelerator.net\/doc\/phpdoc\/\" target=\"_blank\">API Documents<\/a><\/p>\n<p>\u4e0b\u9762\u6709\u90e8\u5206\u7f51\u53cb\u7ffb\u8bd1\u540e\u7684\u63a5\u53e3\u8bf4\u660e\uff1a<\/p>\n<div>\n<div>eaccelerator_put($key, $value, $ttl=0)\n\u5c06 $value \u4ee5 $key \u4e3a\u952e\u540d\u5b58\u8fdb\u7f13\u5b58(php4\u4e0b\u652f\u6301\u5bf9\u50cf\u7c7b\u578b\uff0c\u770b\u6e90\u7801\u597d\u50cfzend2\u91cc\u4e0d\u652f\u6301\u4e86)\uff0c$ttl \u662f\u8fd9\u4e2a\u7f13\u5b58\u7684\u751f\u547d\u5468\u671f\uff0c\u5355\u4f4d\u662f\u79d2\uff0c\u7701\u7565\u8be5\u53c2\u6570\u6216\u6307\u5b9a\u4e3a 0 \u8868\u793a\u4e0d\u9650\u65f6\uff0c\u76f4\u5230\u670d\u52a1\u5668\u91cd\u542f\u6e05\u7a7a\u4e3a\u6b62\u3002eaccelerator_get($key)\n\u6839\u636e $key \u4ece\u7f13\u5b58\u4e2d\u8fd4\u56de\u76f8\u5e94\u7684 eaccelerator_put() \u5b58\u8fdb\u53bb\u7684\u6570\u636e\uff0c\u5982\u679c\u8fd9\u9879\u7f13\u5b58\u5df2\u7ecf\u8fc7\u671f\u6216\u4e0d\u5b58\u5728\u90a3\u4e48\u8fd4\u56de\u503c\u662f NULL\n\neaccelerator_rm($key)\n\u6839\u636e $key \u79fb\u9664\u7f13\u5b58\n\neaccelerator_gc()\n\u79fb\u9664\u6e05\u7406\u6240\u6709\u5df2\u8fc7\u671f\u7684 key\n\neaccelerator_lock($key)\n\u4e3a $key \u52a0\u4e0a\u9501\u5b9a\u64cd\u4f5c\uff0c\u4ee5\u4fdd\u8bc1\u591a\u8fdb\u7a0b\u591a\u7ebf\u7a0b\u64cd\u4f5c\u65f6\u6570\u636e\u7684\u540c\u6b65\u3002\u9700\u8981\u8c03\u7528 eaccelerator_unlock($key) \u6765\u91ca\u653e\u8fd9\u4e2a\u9501\u6216\u7b49\u5f85\u7a0b\u5e8f\u8bf7\u6c42\u7ed3\u675f\u65f6\u81ea\u52a8\u91ca\u653e\u8fd9\u4e2a\u9501\u3002\n\u4f8b\u5982:\n<?php\neaccelerator_lock(\"count\");\neaccelerator_put(\"count\",eaccelerator_get(\"count\")+1));\n?>\n\neaccelerator_unlock($key)\n\u6839\u636e $key \u91ca\u653e\u9501\n\neaccelerator_cache_output($key, $eval_code, $ttl=0)\n\u5c06 $eval_code \u4ee3\u7801\u7684\u8f93\u51fa\u7f13\u5b58 $ttl \u79d2\uff0c\uff08$ttl\u53c2\u6570\u540c eacclerator_put\uff09\n\u4f8b\u5982\uff1a\n<?php\u00a0eaccelerator_cache_output('test',\u00a0'echo time(); phpinfo();',30);\u00a0?>\n\neaccelerator_cache_result($key, $eval_code, $ttl=0)\n\u5c06 $eval_code \u4ee3\u7801\u7684\u6267\u884c\u7ed3\u679c\u7f13\u5b58 $ttl \u79d2\uff0c\uff08$ttl\u53c2\u6570\u540c eacclerator_put\uff09\uff0c\u7c7b\u4f3c cache_output\n\u4f8b\u5982\uff1a\n<?php\u00a0eaccelerator_cache_result('test',\u00a0'\u00a0time() . \"Hello\";',\u00a030);\u00a0?>\n\neaccelerator_cache_page($key, $ttl=0)\n\u5c06\u5f53\u524d\u6574\u9875\u7f13\u5b58 $ttl \u79d2\u3002\n\u4f8b\u5982\uff1a\n<?php\neaccelerator_cache_page($_SERVER['PHP_SELF'].'?GET='.serialize($_GET),30);\necho\u00a0time();\nphpinfo();\n?>\n\neaccelerator_rm_page($key)\n\u5220\u9664\u7531\u00a0 eaccelerator_cache_page() \u6267\u884c\u7684\u7f13\u5b58\uff0c\u53c2\u6570\u4e5f\u662f $key\n\n<\/div>\n<\/div>\n<p>2\u3001PHP\u4ee3\u7801\u4e2d\u4f7f\u7528eAccelerator\u52a0\u901f<\/p>\n<p>\u4e0b\u9762\u6709\u4e00\u4e2a\u6d4b\u8bd5\u7684\u4ee3\u7801\uff0c\u4f60\u53ef\u4ee5\u6d4b\u8bd5\u4e00\u4e0beAccelerator\u5f3a\u5927\u7684\u5a01\u529b\uff1a\uff08\u8be5\u4ee3\u7801\u5728 cli \u6a21\u5f0f\u4e0b\u53ef\u80fd\u65e0\u6548\uff09<\/p>\n<div>\n<div><?php\nclass\u00a0test_cache\u00a0{\nvar\u00a0$pro\u00a0=\u00a0'hello';function\u00a0test_cache()\u00a0{\necho\u00a0\"Object Created!<br>\\n&#8221;;\n}\nfunction\u00a0func()\u00a0{\necho\u00a0&#8216;, the world!&#8217;;\n}\nfunction\u00a0now($t)\u00a0{\necho\u00a0date(&#8216;Y-m-d H:i:s&#8217;,\u00a0$t);\n}\n}\n\n$tt\u00a0=\u00a0eaccelerator_get(&#8220;test_tt&#8221;);\nif\u00a0(!$tt)\n{\n$tt\u00a0=\u00a0new\u00a0test_cache;\neaccelerator_put(&#8220;test_tt&#8221;,\u00a0$tt);\necho\u00a0&#8220;no cached!<br>\\n&#8221;;\n}\nelse\u00a0{\necho\u00a0&#8220;cached<br>\\n&#8221;;\n}\n\necho\u00a0$tt->pro;\n$tt->func();\n$tt->now(time()\u00a0+\u00a086400);\n?>\n\n<\/div>\n<\/div>\n<p>\u53e6\u5916\uff0c\u636e\u8bf4\u5728\u8457\u540d\u7684vBulletin 3.60Beta\u7248\u91cc\u9762\u5df2\u7ecf\u96c6\u6210\u4e86\u5bf9eAccelerator\u7684\u652f\u6301\uff0c\u4e0b\u9762\u662f\u4e00\u6bb5\u6765\u81eavBulletin\u91cc\u9762\u7684\u4ee3\u7801<\/p>\n<div>\n<div>\/\/ #############################################################################\n\/\/ eAccelerator\/**\n* Class for fetching and initializing the vBulletin datastore from eAccelerator\n*\n*\u00a0@package\u00a0\u00a0 \u00a0vBulletin\n*\u00a0@version\u00a0\u00a0 \u00a0$Revision: 0.1 $\n*\u00a0@date\u00a0\u00a0 \u00a0 \u00a0 \u00a0$Date: 2005\/06\/12 13:14:18 $\n*\/\nclass\u00a0vB_Datastore_eAccelerator\u00a0extends\u00a0vB_Datastore\n{\n\/**\n* Fetches the contents of the datastore from eAccelerator\n*\n*\u00a0@param\u00a0\u00a0 \u00a0array\u00a0 \u00a0 Array of items to fetch from the datastore\n*\n*\u00a0@return\u00a0\u00a0 \u00a0void\n*\/\nfunction\u00a0fetch($itemarray)\n{\nif\u00a0(!function_exists(&#8216;eaccelerator_get&#8217;))\n{\ntrigger_error(&#8220;eAccelerator not installed&#8221;,\u00a0E_USER_ERROR);\n}\n\nforeach\u00a0($this->defaultitems\u00a0AS\u00a0$item)\n{\n$this->do_fetch($item);\n}\n\nif\u00a0(is_array($itemarray))\n{\nforeach\u00a0($itemarray\u00a0AS\u00a0$item)\n{\n$this->do_fetch($item);\n}\n}\n\n$this->check_options();\n\n\/\/ set the version number variable\n$this->registry->versionnumber\u00a0=&#038;\u00a0$this->registry->options[&#8216;templateversion&#8217;];\n}\n\n\/**\n* Fetches the data from shared memory and detects errors\n*\n*\u00a0@param\u00a0\u00a0 \u00a0string\u00a0 \u00a0 title of the datastore item\n*\n*\u00a0@return\u00a0\u00a0 \u00a0void\n*\/\nfunction\u00a0do_fetch($title)\n{\n$data\u00a0=\u00a0eaccelerator_get($title);\nif\u00a0($data\u00a0===\u00a0null)\n{\u00a0\/\/ appears its not there, lets grab the data, lock the shared memory and put it in\n$data\u00a0=\u00a0&#8221;;\n$dataitem\u00a0=\u00a0$this->dbobject->query_first(&#8221;\nSELECT title, data FROM\u00a0&#8221;\u00a0.\u00a0TABLE_PREFIX\u00a0.\u00a0&#8220;datastore\nWHERE title = &#8216;&#8221;\u00a0.\u00a0$this->dbobject->escape_string($title)\u00a0.&#8221;&#8216;\n&#8220;);\nif\u00a0(!empty($dataitem[&#8216;title&#8217;]))\n{\n$data\u00a0=&#038;\u00a0$dataitem[&#8216;data&#8217;];\n$this->build($dataitem[&#8216;title&#8217;],\u00a0$dataitem[&#8216;data&#8217;]);\n}\n}\n$this->register($title,\u00a0$data);\n}\n\n\/**\n* Updates the appropriate cache file\n*\n*\u00a0@param\u00a0\u00a0 \u00a0string\u00a0 \u00a0 title of the datastore item\n*\n*\u00a0@return\u00a0\u00a0 \u00a0void\n*\/\nfunction\u00a0build($title,\u00a0$data)\n{\nif\u00a0(!function_exists(&#8216;eaccelerator_put&#8217;))\n{\ntrigger_error(&#8220;eAccelerator not installed&#8221;,\u00a0E_USER_ERROR);\n}\neaccelerator_lock($title);\neaccelerator_put($title,\u00a0$data);\neaccelerator_unlock($title);\n}\n}\n\n<\/div>\n<\/div>\n<p>\u56db\u3001\u9644\u5f55\u548c\u53c2\u8003\u8d44\u6599\neAccelerator \u5b98\u65b9\u7f51\u7ad9 \uff1a<a href=\"http:\/\/eaccelerator.net\">http:\/\/eaccelerator.net<\/a>\nWebsites using eAccelerator ?<\/p>\n<ul>\n<ul>\n    <li>http:\/\/www.advfn.com\/ (2006\/03\/03) Advanced Financial Network, serves over 7 million page hits per day.<\/li>\n    <li>http:\/\/www.domaincity.co.uk\/ (2005\/01\/29) Andrew Hutchings \u2013 Linux Guru \u2013 Just a quick message to say we are now using eaccelerator as a replacement for mmcache on 2 of our 3 node round robin clusters, 2.5million hits per day. We will be doubling this in the next few week, as well as implementing new clusters.<\/li>\n    <li>http:\/\/www.ets-online.de\/ (2005\/02\/07) Denny Reeh \u2013 System Developer \u2013 The e\/t\/s didactic media provides an elearning server (Distance Learning System) written in PHP. We are hosting the systems for our customers mainly by ourself. So we have 5 live-servers (freebsd, apache2, php4, eaccelerator) with 5.5 million hits per month. First without eAccelerator we should have installed more servers for good performance and secondly we improve the customer convenience by quartering the medium response time of a script.<\/li>\n    <li>http:\/\/www.gorgoyle.com\/ (2005\/08\/03) Gorgoyle.com is Yet Another Debian Personal Server with just a few lost Internet wanderers passing by, powered by a glorious Celeron 433 that needed some fresh air\u2026 With eAccelerator the result is quite impressive: users say the server speed is now 10000% higher (no joke!) So thank you all and keep up the good work!!! Server: eAccelerator 0.9.5 beta 1 Apache\/2.0.55 (Debian) mod_python\/3.1.3 Python\/2.3.5 PHP\/4.4.2-1 mod_ssl\/2.0.55 OpenSSL\/0.9.8a mod_perl\/2.0.2<\/li>\n    <li>http:\/\/www.mafia-inc.de\/ (2005\/05\/24) The Mafia-Incorporated is a succesfull Browser game with around 2.500.000 page impressions each day and over 5000 users. Server: PHP Version 4.3.10-9, eAccelerator 0.9.2a, Debian , Apache 2.0.53<\/li>\n    <li>http:\/\/www.mondespersistants.com\/ (2005\/01\/07) An other game oriented french website with 6 000 000 pageloads monthly. http:\/\/guildes.mondespersistants.com is a full PHP5 oo development. Theses websites are running under freebsd \/ apache 1.3 \/ php 5.0.3 \/ eaccelerator 0.9.2<\/li>\n    <li>http:\/\/www.moviemaze.de\/ (2005\/12\/09) Markus Ostertag \u2013 Movie Maze is a large german online-magazine with trailer, wallpaper, reviews, news and much more. Currently we use three servers (Suse &#038; Debian with Apache 2, PHP4) with eAccelerator and provide more than 3TB data to ~1 Mio. users each month.<\/li>\n    <li>http:\/\/www.rtvslo.si (2005\/01\/04) The Slovenian National RTV Station and its news\/misc portal with forums. Over 3500 users and more than 37000 forum messages in a year. Two round-robin servers for the masses, and an administrator server. 6 000 000 pageloads monthly.<\/li>\n    <li>http:\/\/www.shroomery.org\/ (2006\/03\/28) A site about mushrooms and mycology, serving 20,000,000 pages per month. Web and database server are identical dual 64-bit Xeons with 4GB and SCSI RAID5 running Gentoo. eAccelerator help keep our page generation time under .1 second!<\/li>\n    <li>\n    <li>http:\/\/www.sourceforge.net\/ (2005\/04\/25) SourceForge.net is the world\u2019s largest Open Source software development web site, hosting more than 100,000 projects and over 1,000,000 registered users with a centralized resource for managing projects, issues, communications, and code. SourceForge.net has the largest repository of Open Source code and applications available on the Internet, and hosts more Open Source development products than any other site or network worldwide. SourceForge.net provides a wide variety of services to projects we host, and to the Open Source community. eAccelerator is used on the webserver cluster for their frontpage.<\/li>\n<\/ul>\n<\/ul>\n<p>Companies offering hosting with eAccelerator enabled ?<\/p>\n<ul>\n    <li>http:\/\/lylix.net\/ (2006\/04\/29) Offering webhosting w\/ Apache\/2.0.55, PHP 5.0.5, and eAccelerator 0.9.5 beta1 on Gentoo Linux servers. Also a provider of quality Virtual Private Server (VPS) hosting, including 32 and 64-bit platforms. Most VPS images have a pre-installed LAMP environment w\/ eAccelerator installed and configured.<\/li>\n    <li>http:\/\/www.ulyssis.org A student organisation which provides shell and internet services for students at very cheap prices.<\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Trackback URL:\u00a0<a href=\"http:\/\/www.toplee.com\/blog\/wp-trackback.php?p=100\">http:\/\/www.toplee.com\/blog\/wp-trackback.php?p=100<\/a> \u524d\u4e00\u6bb5\u65f6\u95f4\u5b8c\u6210\u4e86\u670d\u52a1\u5668\u4eceFreeBSD4.10\u52306.1\u7684\u5347\u7ea7\uff0c\u540c\u65f6\u628aP&#46;&#46;&#46;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,15],"tags":[245,323,442],"class_list":["post-842","post","type-post","status-publish","format-standard","hentry","category-linux","category-php","tag-ea","tag-eaccelerator","tag-php"],"_links":{"self":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/comments?post=842"}],"version-history":[{"count":3,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/842\/revisions"}],"predecessor-version":[{"id":850,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/842\/revisions\/850"}],"wp:attachment":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/media?parent=842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/categories?post=842"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/tags?post=842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}