[英]PHP memcached client - does its CRC32 work across 32 and 64bit servers?
[英]PHP memcached for Windows XP 32 bit
如何在 Windows XP 32 位中安装 memcached?
我可以成功安装 memcache 并且可以使用以下代码
$m = new Memcache;
$m->connect('localhost',11211);
但我需要像这样使用 memcached,
$m = new Memcached();
$servers = array(
array('localhost', 11211)
);
$m->addServers($servers);
现在上面的代码显示找不到 Memcached 类。 由于它没有安装。 那么如何在 Windows XP 32 位中安装 memcached
我有一个类似的问题,对于那些不想(或不能,无论出于何种原因)运行虚拟机的人,我最终得到了在 Windows 上运行和在 linux 上运行的不同代码。
当我运行以下命令时:
$m = new Memcache;
print_r(get_class_methods($m));
我注意到, Memcache
不具有AddServers()
方法,这东西对于Memcached
(见在内存缓存类php.net文档相比于Memcached的类php.net文档和通知有很多更Memcached
!)。
因此,对于 Windows(您需要使用Memcache
,没有Memcached
可用),解决方案是创建您自己的短循环来添加多个服务器:
$m = new Memcache();
$servers = array(
array('localhost', 11211),
// ... other servers here
);
foreach ($servers as $s) $m->addServer($s[0], $s[1]);
如果您需要同时提供适用于 Windows 和 Linux 的两套代码,您总是可以将上述代码括在if (PHP_OS == 'WINNT')
,并将您的 Linux 代码放在它后面的 else 语句中。 所以,类似于:
$servers = array(
array('localhost', 11211),
// ... other servers here
);
if (PHP_OS == 'WINNT') {
$m = new Memcache();
foreach ($servers as $s) $m->addServer($s[0], $s[1]);
}
else {
$m = new Memcached();
$m->addServers($servers);
}
和你有同样的问题。
在阅读http://shikii.net/blog/installing-memcached-for-php-5-3-on-windows-7/ 之后,我发现由于 libmemcached,Memcached 是为 linux 设计的。
仍在等待有关此问题的正确解决方案。
有没有人可以帮助我们? 谢谢你。
*对不起,我的英语不好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.