简体   繁体   English

Memcached无法在Codeigniter上运行

[英]Memcached is not working on codeigniter

I am trying to use the memcached for my large database queries. 我正在尝试对大型数据库查询使用memcached。 So far, I have installed the memcached services and it is running fine. 到目前为止,我已经安装了memcached服务,并且运行良好。 Another thing which I am unable to find is php_memcached.dll file for windows 7, 64 bit. 我找不到的另一件事是Windows 7(64位)的php_memcached.dll文件。 There are few but they talk about php_memcache.dll . 很少,但是他们谈论php_memcache.dll I have installed that one and I can see in the Wamp->PHP->PHP extentions that the extension is running. 我已经安装了该扩展程序,并且可以在Wamp->PHP->PHP extentions看到该扩展正在运行。 Finally, I have created the memcached.php file in the application/config/ directory and put the following code: 最后,我在application/config/目录中创建了memcached.php文件,并输入以下代码:

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config = array(
    'default' => array(
        'host'      => 'localhost',
        'port'      => 11211,
        'weight'    => 1
    )
);
?>

Whenever I se phpinfo(); 每当我看到phpinfo(); I am unable to locate that memcached is configured. 我无法找到已配置的memcached。 I do not know where I am going wrong. 我不知道我要去哪里错了。 I reckon this is because I have installed memcached service and php_memcache.dll extension. 我认为这是因为我已经安装了memcached服务和php_memcache.dll扩展名。 Is this could be the reason ?? 这可能是原因吗?

Or what could be potentially reason that it is not working on codeigniter.? 还是可能导致它无法在Codeigniter上工作的原因?

codeigniter is trying to load the php memcached extension which is most likely not the one that comes with your windows installation. codeigniter正在尝试加载php memcached扩展,该扩展很可能不是Windows安装随附的扩展。 You will need to modify cached_memcached.php file located in the libraries folder. 您将需要修改库文件夹中的cached_memcached.php文件。

and find this line 并找到这条线

$this->memcached = new Memcached();

replace it with 替换为

 $this->memcached = new Memcache();

you can also choose to install the php memcached extension through pecl 您还可以选择通过pecl安装php memcached扩展

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM