Re: [Catalyst] clear() method for Catalyst::Plugin::Cache?

2009-03-11 Thread Tomas Doran

Larry Leszczynski wrote:

But I see your point about the danger of
clearing/flushing more than you might expect.  Regardless of cache
flavor, you could set up separate backend instances for different pools
of data (via e.g. different cache_roots for Cache::FileCache or
different server instances for Cache::Memcached::libmemcached) and make
sure you only clear() the intended backend.
  
I'd be against the method being called 'clear' as it'd be waaay to easy 
to misread the api and say $cache-clear($key)... Oops.


But having a general facility to map 
-remove_the_entire_contents_of_the_cache_yes_i_really_want_to_do_this 
(ok, maybe not quite that method name as thats a little OTT in the other 
direction) to the appropriate handwave for your specific backend sounds 
reasonable, as long as its appropriately documented..


So patch away!

Cheers
t0m





___
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/


[Catalyst] clear() method for Catalyst::Plugin::Cache?

2009-03-06 Thread Larry Leszczynski
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 can try to work up patches if there's a consensus that it makes sense
to do...

Larry

___
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/


Re: [Catalyst] clear() method for Catalyst::Plugin::Cache?

2009-03-06 Thread Jason Kohles

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/


Re: [Catalyst] clear() method for Catalyst::Plugin::Cache?

2009-03-06 Thread Larry Leszczynski

On Fri, 06 Mar 2009 20:11 -0500, Jason Kohles em...@jasonkohles.com
wrote:
 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.

Actually, not using it for session caching at all, just other various
bits and pieces of data.  But I see your point about the danger of
clearing/flushing more than you might expect.  Regardless of cache
flavor, you could set up separate backend instances for different pools
of data (via e.g. different cache_roots for Cache::FileCache or
different server instances for Cache::Memcached::libmemcached) and make
sure you only clear() the intended backend.


Larry

___
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/