gitweb/lib - Use CHI compatibile (compute method) caching interface
commit7e1cadb741c8b183accb66447a7cd8f37d5406a1
authorJakub Narebski <jnareb@gmail.com>
Sun, 5 Dec 2010 20:48:56 +0000 (5 21:48 +0100)
committerJakub Narebski <jnareb@gmail.com>
Sun, 5 Dec 2010 20:48:56 +0000 (5 21:48 +0100)
treed8b5c5374344aba6bc6e45d82440792a83d942a3
parent6307fd4d48add6acc9643eeb25880be949481bdb
gitweb/lib - Use CHI compatibile (compute method) caching interface

If $cache provides CHI compatible ->compute($key, $code) method, use it
instead of Cache::Cache compatible ->get($key) and ->set($key, $data).
In the future other compatibile but differently named methods, like
Cache::FastMmap's ->get_and_set($key, $code) method, could also be
supported; though CHI which has ->compute() includes CHI::Driver::FastMmap
wrapper.

GitwebCache::SimpleFileCache provides 'compute' method, which currently
simply use 'get' and 'set' methods in proscribed manner.  Nevertheless
'compute' method can be more flexible in choosing when to refresh cache,
and which process is to refresh/(re)generate cache entry.  This method
would use (advisory) locking to prevent 'cache miss stampede' (aka
'stampeding herd') problem in the next commit.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
gitweb/lib/GitwebCache/CacheOutput.pm