CakePHP + NGINX + Memcache [英] CakePHP + NGINX + Memcache

查看:166
本文介绍了CakePHP + NGINX + Memcache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在NGINX上使用Memcache的CakePHP(2.4.7),但是当我更新core.php& bootstrap.php这样做我会抛出以下异常:

I am trying to use Memcache on NGINX for CakePHP (2.4.7) but when I update the core.php & bootstrap.php to do this I am then thrown the following exception:

致命错误:未捕获异常CacheException消息缓存引擎_cake_core_未正确配置

如果需要任何其他配置,但我没有看到任何内容,我已尝试搜索。任何帮助将不胜感激。

I have tried to search if any other configuration is required but can't see anything. Any help would be appreciated

感谢,

推荐答案

您需要确保您的Memcached配置和工作正常。
检查memcached端口(默认设置为11211)/ process等...例如memcached -u www-data -vv。
然后如果你使用memcached默认配置,你应该更改core.php配置,如下所示:
取消注释有关memcached的部分。之后它应该看起来像这样:

First of all you need be sure that your Memcached configured and working properly. Check memcached port (11211 if default settings) / process etc... for example memcached -u www-data -vv. Then if you using memcached default configurations you should change core.php configurations like following: Uncomment section about memcached. After it it's should looks like this:

Cache::config('default', array(
'engine' => 'Memcache', //[required]
'duration' => 1800, //[optional]
'probability' => 100, //[optional]
'prefix' => Inflector::slug(APP_DIR) . '_',
'servers' => array(
    '127.0.0.1:11211'),
'persistent' => true,
'compress' => false));

现在更改$ engine ='File'; to $ engine ='Memcache';

Now change $engine = 'File'; to $engine = 'Memcache';

例如在控制器中使用缓存,您需要使用key => value写入数据,然后使用键访问该数据。示例:

Use caching for example in controller you need write data with key => value, then access that data with key. Example:

Cache::write($key, $value);
Cache::read($key);


希望它帮助你。

That's all. Hope it's help you.

这篇关于CakePHP + NGINX + Memcache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆