一、在window php 操作memcached 需要找到合適的擴充,擴充在官方下載,地址是:
PHP 5.2/5.3的Windows擴充索引網站:
在這裡你可以找到諸如php_oci8.dll, php_memcache.dll, php_mongo.dll, php_apc.dll等常用的Windows擴充dll檔案,也能找到一些相對冷門但是也很實用的php擴充,如php_oauth.dll, php_solr.dll等擴充
http://downloads.php.net/pierre/
PHP 5.3/5.4/5.5的Windows擴充索引網站:
那麼你就需要到下面這個網站來找擴充了, 該網站能下載到支援php5.4/5.5的pecl擴充,
http://windows.php.net/downloads/pecl/releases/
支援的擴充檔案索引:
php_amqp.dll
php_aop.dll
php_apc.dll
php_apcu.dll
php_automap.dll
php_bbcode.dll
php_bitset.dll
php_blenc.dll
php_couchbase.dll
php_dbx.dll
php_dio.dll
php_docblock.dll
php_doublemetaphone.dll
php_excel.dll
php_fann.dll
php_fribidi.dll
php_gender.dll
php_geoip.dll
php_haru.dll
php_htscanner.dll
php_http.dll
php_ibm_db2.dll
php_igbinary.dll
php_imagick.dll
php_inclued.dll
php_jsmin.dll
php_jsonc.dll
php_judy.dll
php_libevent.dll
php_lzf.dll
php_mailparse.dll
php_memcache.dll
php_memoize.dll
php_memsession.dll
php_memtrack.dll
php_mongo.dll
php_msgpack.dll
php_mysqlnd_ms.dll
php_mysqlnd_qc.dll
php_oauth.dll
php_oci8.dll
php_opcache.dll
php_operator.dll
php_pdflib.dll
php_pdo_4d.dll
php_pdo_ibm.dll
php_pdo_informix.dll
php_pdo_sqlanywhere.dll
php_pdo_sqlsrv.dll
php_pthreads.dll
php_radius.dll
php_rar.dll
php_riak.dll
php_scream.dll
php_solr.dll
php_sphinx.dll
php_spl_types.dll
php_sqlsrv.dll
php_ssh2.dll
php_stats.dll
php_stem.dll
php_stomp.dll
php_taint.dll
php_trader.dll
php_translit.dll
php_txforward.dll
php_uploadprogress.dll
php_uri_template.dll
php_varnish.dll
php_vld.dll
php_weakref.dll
php_win32ps.dll
php_win32service.dll
php_wincache.dll
php_xdebug.dll
php_xdiff.dll
php_xhprof.dll
php_xrange.dll
php_xslcache.dll
php_yaf.dll
php_yaml.dll
php_zip.dll
php_zmq.dll
二、那麼多的擴充如何找到合適的擴充需要注意一下三點:
代碼phpinfo(); 看php 的相關資訊,php版本號碼,
Compiler |
MSVC9 (Visual C++ 2008) |
上面是php 是用什麼編輯的
還有
Zend Extension Build |
API220090626,TS,VC9 |
ts表示安全的,nts 表示非安全的不是用web執行而是用內部服務執行:
說了這麼多參考我上面的主要是版本號碼 TS VC9,
二、我找到了下面的擴充
Tuesday, October 22, 2013 1:19 AM 182281 php_memcache-3.0.8-5.4-ts-vc9-x86.zip
解壓到php 放擴充的地方 extension_dir = "D:/wamp/bin/php/php5.3.10/ext/"
在php.ini ,添加擴充extension=php_memcache.dll 關於php.ini 可以在
Loaded Configuration File |
D:\wamp\bin\apache\Apache2.2.21\bin\php.ini |
中找到,為什麼,由於php在安裝時可有會同時複製一個設定檔作為副本。
三、重新啟動apache 就可以了。
三、window memcached 安裝成服務
memcached.exe -d install
memcached.exe -d start 四、php 操作memcached 的一個測試例子:
$memcache = memcache_connect('127.0.0.1',11211);if ($memcache) { $memcache->set("str_key", "String to store in memcached"); $memcache->set("num_key", 123); $object = new StdClass; $object->attribute = 'test'; $memcache->set("obj_key", $object); $array = Array('assoc'=>123, 345, 567); $memcache->set("arr_key", $array); var_dump($memcache->get('str_key')); var_dump($memcache->get('num_key')); var_dump($memcache->get('obj_key')); $ar=$memcache->get('arr_key') ; echo gettype($ar);}else { echo "Connection to memcached failed";}
以上只介紹關鍵的部分,其它的不知道請留言。