一、在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) |
还有
Zend Extension Build | API220090626,TS,VC9 |
说了这么多参考我上面的主要是版本号 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"; }
以上只介绍关键的部分,其它的不知道请留言。