Reputation: 2525
I'm setting up cacheing for a CakePHP application and having a really hard time getting it to talk to Memcache.
I've written the caching code while testing against the File based caching engine, and all the logic is solid. When I watch debug traffic, caches hit, miss, and expire properly. I wanted to switch over to Memcache because the Filesytem based cache doesn't really offer any performance improvement, but I can't seem to get it to work at all.
As soon as I change the Caching engine in Cache::config to Memcache, I get the following error:
Warning (512): Cache not configured properly. Please check Cache::config(); in APP/config/core.php [CORE/cake/libs/configure.php, line 663]
This happens with a simple configuration call, like:
Cache::config('default', array(
'engine' => 'Memcache'
));
Or a more complicated one, like the default one suggested in core.php:
Cache::config('default', array(
'engine' => 'Memcache', //[required]
'duration'=> 3600, //[optional]
'probability'=> 100, //[optional]
'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
'servers' => array(
'127.0.0.1:11211' // localhost, default port 11211
), //[optional]
'compress' => false, // [optional] compress data in Memcache (slower, but uses less memory)
));
Cache.check is set to true, eg Configure::write('Cache.check', true);
and Cache.disable is not set. Again, all the caching logic works great as long as I'm using 'engine' => 'File'
.
I get the same error whether memcached is running or not. This error seems to encompass a ton of different problems - extensive searching has revealed a huge variety of potential solutions to problems with this error message. I've double checked that my tmp directories exist (per http://ryan.ifupdown.com/2009/08/05/warning-512-cache-not-configured-properly-please-check-cacheconfig-in-appconfigcore-php-corecakelibsconfigure-php-line-663/), I'm running on Ubuntu, so there are no pathing issues (which have been a problem in the past, per https://trac.cakephp.org/ticket/4433 and http://cakephp.1045679.n5.nabble.com/cake-1-2-problem-with-cache-td1302563.html). I am running a relatively old version of Cake (1.2.5), but I tried upgrading and had the same error message (along with a million other upgrade-related errors that I don't really have time to hunt down.)
Is there any way to get more detailed information out of Cake about what's actually going wrong? I get the feeling that this error is just a catch-all error for anything that goes wrong in the cache class initialization, and there are tons of potential problems. Changing the debug level up to 3 doesn't reveal anything more. If I could get more info I might be able to do something, but I'm totally flying blind. I'm a mostly-novice Cake user, so any general guidance about best practices for dealing with bizarre Cake bugs would be much appreciated!
Upvotes: 4
Views: 10584
Reputation: 7938
You have to make sure the memcache
(not "memcached
") is 1) installed and 2) running.
1) Check if extension=memcache.so
is present in php.ini
2) Follow this instructions to start automatically memcache
Upvotes: 0
Reputation: 11
On Ubuntu 10.04, I had to install both memcached AND memcache in order to get it to work.
Upvotes: 1
Reputation: 178
You need to install the Memcache lib for PHP. You should be able to install it using the "php5-memcache" package.
Upvotes: 4
Reputation: 2702
Usually this means that the memcache server isn't actually running. Can you make sure that the server is running locally, and on port 11211 (which is the default)?
Upvotes: 0