CakePHP + NGINX + Memcache

微笑、不失礼 提交于 2019-12-13 20:30:37

问题


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:

Fatal error: Uncaught exception 'CacheException' with message 'Cache engine _cake_core_ is not properly configured

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

Thanks,


回答1:


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));

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

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.



来源:https://stackoverflow.com/questions/23181665/cakephp-nginx-memcache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!