Wednesday, January 16, 2013

Cache::cleargroup() doesn't make sense to me

According to:
http://book.cakephp.org/2.0/en/core-libraries/caching.html#using-groups

"Groups are shared across all cache configs using the same engine and same prefix. If you are using groups and what to take advantage of group deletion, choose a common prefix for all your configs."

So this seems that you can use cleargroup() to clear a specified group across all cache configs.  But then why does cleargroup() take a config as a parameter which defaults to "default"?

How is it going to clear the specified group across all configs if it defaults to the "default" config?  Am I supposed to call it multiple times specifying a different cache config each time? Seems to defeat the purpose of groups.

ex:
Cache::config('short', array(
    'engine' => 'File',
    'duration'=> 60,
    'serialize' => true,
    'prefix' => 'CA',
    'groups' => array('posts')
));

Cache::config('med', array(
    'engine' => 'File',
    'duration'=> 180,
    'serialize' => true,
    'prefix' => 'CA',
    'groups' => array('posts')
));

Cache::config('long', array(
    'engine' => 'File',
    'duration'=> 300,
    'serialize' => true,
    'prefix' => 'CA',
    'groups' => array('posts')
));

So for the above, according to the docs and api
Cache::cleargroup('posts')
would clear "posts" group but only if using the 'default' config. 

Am I missing something?


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: