gitweb/lib - Stat-based cache expiration
Add stat-based cache expiration to file-based GitwebCache::SimpleFileCache.
Contrary to the way other caching interfaces such as Cache::Cache and CHI
do it, the time when cache element expires in is _global_ value associated
with cache instance, and is not local property of cache entry. (Currently
cache entry does not store any metadata associated with entry... which
means that there is no need for serialization / marshalling / freezing and
thawing.) Default expire time is -1, which means never expire.
To check if cache entry is expired, GitwebCache::SimpleFileCache compares
difference between mtime (last modify time) of a cache file and current time
with (global) time to expire. It is done using CHI-compatible is_valid()
method.
Includes some tests checking that expiring works correctly (on the level of
API) in t9503.
Inspired-by-code-by: John 'Warthog9' Hawley <warthog9@kernel.org>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>