【问题标题】:CakePHP Memcached CakePHP2.5.xCakePHP Memcached CakePHP2.5.x
【发布时间】:2014-08-12 19:37:31
【问题描述】:
我已经升级到 CakePHP 2.5.x 系列,现在尝试实现新的 Memcached 引擎来替代 Memcache;但是我得到以下信息:
_cake_core_ 缓存无法将“cake_dev_en-us”写入...中的 Memcached 缓存
未捕获的异常“CacheException”和消息“不是 Memcached 的有效序列化引擎”
我已经用正确的值更新了 bootstrap.php 和 core.php。 Memcached 在我的 Ubuntu 14.04 服务器上使用 localhost (127.0.0.1) 上的端口 11211 正常工作。任何帮助将不胜感激
谢谢
【问题讨论】:
标签:
cakephp
memcached
cakephp-2.5
【解决方案1】:
这是因为在 Config/core.php 中,如果缓存引擎设置为“Memcached”,后面的 'serialize' 参数将设置为 false,但是,MemcachedEngine 要求在 'php 中设置 'serialize' '、'igbinary' 和 'json'。您可以只注释掉“serialize”这一行,所以 'php' 将是默认值。
/**
* Configure the cache used for general framework caching. Path information,
* object listings, and translation cache files are stored with this configuration.
*/
Cache::config('_cake_core_', array(
'engine' => $engine,
'prefix' => $prefix . 'cake_core_',
'path' => CACHE . 'persistent' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration
));
/**
* Configure the cache for model and datasource caches. This cache configuration
* is used to store schema descriptions, and table listings in connections.
*/
Cache::config('_cake_model_', array(
'engine' => $engine,
'prefix' => $prefix . 'cake_model_',
'path' => CACHE . 'models' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration
));