memcached 无法在 codeigniter 2.1.0 上运行

发布于 2024-12-28 09:29:32 字数 787 浏览 1 评论 0原文

一段时间以来我一直在努力让它发挥作用,但我做不到。我正在 Windows 7 64 位上工作,我有 Memcached 服务器作为服务运行,我在 PHP 5.3.8 中有 php_memcached.dll 扩展,当我在 Codeigniter 中的应用程序上调用它时,我以正确的方式执行此操作(我认为)。

$this->load->driver('cache', array('adapter' => 'memcached', 'backup' => 'file'));
var_dump($this->cache->memcached->is_supported());
die();

但它抛出一个错误,所以我不知道我做错了什么。当我这样调用它时:

$this->load->driver('cache', array('adapter' => 'memcached', 'backup' => 'file'));
$data = $this->cache->memcached->get('data_' . $idData);

我收到此 PHP 错误:

Fatal error: Call to a member function get() on a non-object in E:\workspace\example\system\libraries\Cache\drivers\Cache_memcached.php on line 50

感谢您的帮助:-)

I have been trying to make it work for sometime now, but I can't. I am working on a Windows 7 64bits, I have the Memcached Server running as Service, I have the php_memcached.dll extension in the PHP 5.3.8 and when I call it on the app in Codeigniter I do it the right way (I Think).

$this->load->driver('cache', array('adapter' => 'memcached', 'backup' => 'file'));
var_dump($this->cache->memcached->is_supported());
die();

but it throws a false so I don't know what I am doing wrong. When I call it like this:

$this->load->driver('cache', array('adapter' => 'memcached', 'backup' => 'file'));
$data = $this->cache->memcached->get('data_' . $idData);

I get this PHP error:

Fatal error: Call to a member function get() on a non-object in E:\workspace\example\system\libraries\Cache\drivers\Cache_memcached.php on line 50

Thanks for the help :-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

溺ぐ爱和你が 2025-01-04 09:29:32

CI 驱动程序正在寻找 Apache 模块,但在 WIN 中我们主要使用 PHP 类 Memcache。

尝试更改 /system/libraries/Cache/drivers/Cache_memcached.php 中的第 165 行

$this->_memcached = new Memcached();

对我来说,它在从 Memcached 更改为 Memcache 后有效。

$this->_memcached = new Memcache();

The CI driver is looking for the Apache Module, but in WIN we use mostly the PHP-Class Memcache.

Try to change Line 165 in /system/libraries/Cache/drivers/Cache_memcached.php

$this->_memcached = new Memcached();

For me it works after changing from Memcached to Memcache.

$this->_memcached = new Memcache();
分開簡單 2025-01-04 09:29:32

我知道这已经很旧了,但我刚刚遇到了同样的问题。

在 Windows 上,您应该使用“Memcache”而不是“Memcached”。为此,请按照本页上的说明进行操作:
http://www.leonardaustin.com /technical/how-to-install-memcached-on-xampp-on-windows-7

然后,要使其在 CI 中工作,您需要进行两个小更改\system\libraries\Cache\drivers\Cache_memcached.php:

在函数 is_supported() 中,替换:

if ( !extension_loaded('memcached'))

为:

if ( !extension_loaded('memcached') && !extension_loaded('memcache'))

在函数 _setup_memcached() 中,替换:

$this->memcached = new Memcached();

为:

if(class_exists("Memcached"))
  $this->_memcached = new Memcached();
else
  $this->_memcached = new Memcache();

I know this is old, but I just came across the same issue.

On Windows, you should be using "Memcache" rather than "Memcached". To do this, follow the instructions on this page:
http://www.leonardaustin.com/technical/how-to-install-memcached-on-xampp-on-windows-7

Then, to get it working in CI, you'll need to make two small changes to \system\libraries\Cache\drivers\Cache_memcached.php:

In function is_supported(), replace:

if ( !extension_loaded('memcached'))

With:

if ( !extension_loaded('memcached') && !extension_loaded('memcache'))

And in function _setup_memcached(), replace:

$this->memcached = new Memcached();

With:

if(class_exists("Memcached"))
  $this->_memcached = new Memcached();
else
  $this->_memcached = new Memcache();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文