gitweb/lib - Very simple file based cache
commitc3bc3a320def25d691c81ab1c20be4f1204f49aa
authorJakub Narebski <jnareb@gmail.com>
Sun, 5 Dec 2010 20:48:47 +0000 (5 21:48 +0100)
committerJakub Narebski <jnareb@gmail.com>
Sun, 5 Dec 2010 20:48:47 +0000 (5 21:48 +0100)
treefb5c89c95471cbf5d7f3413cac3ffd5e2b6c325d
parentea2fa4c976d013717a4bbc7f35b6aae211b688e9
gitweb/lib - Very simple file based cache

This is first step towards implementing file based output (response)
caching layer that is used on such large sites as kernel.org.

This patch introduces GitwebCaching::SimpleFileCache package, which
follows Cache::Cache / CHI interface, although do not implement it
fully.  The intent of following established convention for cache
interface is to be able to replace our simple file based cache,
e.g. by the one using memcached.

The data is stored in the cache as-is, without adding metadata (like
expiration date), and without serialization (which means that one can
store only scalar data).  At this point there is no support for
expiring cache entries.

The code of GitwebCaching::SimpleFileCache package in gitweb/lib
was heavily based on file-based cache in Cache::Cache package, i.e.
on Cache::FileCache, Cache::FileBackend and Cache::BaseCache, and on
file-based cache in CHI, i.e. on CHI::Driver::File and CHI::Driver
(including implementing atomic write, something that original patch
lacks).  It tries to follow more modern CHI architecture, but without
requiring Moose.  It is much simplified compared to both interfaces
and their file-based drivers.

This patch does not yet enable output caching in gitweb (it doesn't
have all required features yet); on the other hand it includes tests
of cache Perl API in t/t9503-gitweb-caching-interface.sh.

Inspired-by-code-by: John 'Warthog9' Hawley <warthog9@kernel.org>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
gitweb/lib/GitwebCache/SimpleFileCache.pm [new file with mode: 0644]
t/t9503-gitweb-caching-interface.sh [new file with mode: 0755]
t/t9503/test_cache_interface.pl [new file with mode: 0755]