gitweb/lib - Add clear() and size() methods to caching interface
commit10f94c3cf8530e4a10d4fe5825af90a2cb9f0e1a
authorJakub Narebski <jnareb@gmail.com>
Sun, 5 Dec 2010 23:01:10 +0000 (6 00:01 +0100)
committerJakub Narebski <jnareb@gmail.com>
Sun, 5 Dec 2010 23:01:10 +0000 (6 00:01 +0100)
treeb4f854163ce57fa3148ca87dc14fa7047f48f94c
parent27ec67ad90ecd56ac3d05f6a9ea49b6faabf7d0a
gitweb/lib - Add clear() and size() methods to caching interface

Add ->size() method, which following Cache::Cache interface returns
estimated total size of all entries in whole cache (in the namsepace
assiciated with give cache instance).  Note that ->get_size($key)
returns size of a single entry!

Add ->clear() method, which removes all entries from the namespace
associated with given cache instance.  For safety it requires
namespace to be set to true value, which means that it cannot be
empty; therefore default namespace is changed to 'gitweb'.

The ->clear() method should be fairly safe, because it first renames
directory (which should be atomic), and only then removes it
(following code from CGI::Driver::File).

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
gitweb/lib/GitwebCache/SimpleFileCache.pm
t/t9503/test_cache_interface.pl