Memcached (not memcache) PHP extension on Windows

大憨熊 提交于 2019-11-30 01:46:03

问题


I can't seem to find the MemcacheD extension for PHP.

There are a few compilations of php_memcache.dll, but that's not the same.

The main thing I'm missing is getMulti(), which doesn't exist in Memcache.

So far I found this, but there's no DLL:

http://pecl.php.net/package/memcached


回答1:


Officially - it does not exist. There are several people who have created their own DLL's though. Here is one person's blog who has created the dll:

http://trondn.blogspot.com/2010/07/libmemcached-on-win32.html

Here is a link to the repository with the source so you can build your own DLL for memcached:

http://bazaar.launchpad.net/~trond-norbye/libmemcached/mingw32/files




回答2:


I know the memcached has some other features but its interface is nearly identical with that of memcache extension. You can very easily get away with such code and in my case it works perfectly well. If you don't have the memcached loaded create this file:


<?php

    class Memcached {
       const OPT_LIBKETAMA_COMPATIBLE = true;
       const OPT_COMPRESSION = true;
       const OPT_NO_BLOCK = true;
       //if you code relies on any other constants define them to avoid
       //undefined constant notice

       //http://www.php.net/manual/en/memcached.constants.php

       public $_instance;
       public function __construct() {
            $this->_instance = new Memcache;
       }

       public function __call($name, $args) {
            return call_user_func_array(array($this->_instance, $name), $args);
       }

       public function setOption() {}
    }


Either include it or configure autoloader to pick it up. Of course you'll need a properly configured memcache instance and addServer calls but such calls should already be in the code if the codebase assumes Memcached. I hope it helps someone/




回答3:


Here are some link to get memcache.dll according to your PHP version. Tester on Windows 8, WAMP, PHP 5.4.12

http://www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/

Or directly on mediafire :

http://www.mediafire.com/php-win64-extensions

Search there for your version.



来源:https://stackoverflow.com/questions/14243745/memcached-not-memcache-php-extension-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!