سؤال

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,

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top