On Mar 6, 2009, at 7:42 PM, Larry Leszczynski wrote:

Does it make sense to add a clear() method to Catalyst::Plugin::Cache,
in addition to the existing get(), set() and remove()? It seems like a
common action for cache manipulation.

Any of the various Cache::Cache-based backend flavors should be able to
support it out of the box.  For specific backends that use a different
method name to accomplish clearing the cache (e.g.
Cache::Memcached::libmemcached::flush_all), would need to come up with a
way to map method names - maybe a config option?:

   __PACKAGE__->config->{'Plugin::Cache'}{backend} = {
       class   => "Cache::Memcached::libmemcached",
       method_map => {
                      clear => 'flush_all',
                     },
       servers => ['127.0.0.1:11211'],
       debug   => 2,
   };

I think this code is a great example of why this is a bad idea as a general practice. If the only thing you are using memcached for is session cache, then mapping clear to flush_all has the desired effect, but if you are using memcached for more than just session caches, then flush_all could be a very bad idea.

And if you are using memcached for just session cache, then adding your own code to call flush_all when you want to clear it isn't that big a deal. Personally I can't recall ever running into a situation where I had a reason to dump the entire session cache.

--
Jason Kohles, RHCA RHCDS RHCE
em...@jasonkohles.com - http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire



_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to