Tuesday, April 8, 2014

Cache Memcache engine help

I have / think Memcache engine is set up correct. (v 2.4.6)

 

Core.php:

$engine = 'Memcache';

Cache::config('inmemory', array(

                'engine' => 'Memcache',

                'duration' => 3600,

                'serialize' => true,

                'servers' => array(

                                '127.0.0.1:11211'),

                                'persistent' => true,

                                'compress' => false));

 

And a File cache:

Cache::config('default', array( 

                'engine' => 'File',

                'prefix' => '',

                'duration'=> '+1 week', 

                'path' => CACHE . 'default' . DS,));

 

If I check the server the memcache shows the data being cached, the record_ c6a82b1532947c1c8111327581487e74 exists. But in the Model Callback I want to delete the cached record on save / delete.

Check the database and records are getting saved / updated / deleted but the cache "inmemory" never gets deleted. Only if I use "default" does it actually cache the record and delete in the call backs.

 

Aftersave / afterdelete::

$cache_id = md5($this->id);

Cache::delete('record_'.$cache_id, 'inmemory');

 

But it does not delete.

 

If I change it to

Cache::delete('record_'.$cache_id, 'default');

It will delete the record.

 

 

Any ideas?

 

Thanks,

Dave

No comments: