Sorry, a few more comments:
Am 10. Juni 2011 15:36 schrieb René Nussbaumer <[email protected]>:
> --- /dev/null
> +++ b/lib/cache.py
> +class CacheBase:
> + def __init__(self):
> + """Base init method.
> +
> + """
You don't need this, this is the default implementation.
> + def Store(self, key, value, ttl=0):
> + """Stores key with value in the cache.
> +
> + @param key: The key to associate this cached value
> + @param value: The value to cache
> + @param ttl: TTL in seconds after when this entry is considered outdated
> + @returns True on success, False on failure
@return: C{True} on success, …. Here and elsewhere.
> +
> + """
> + raise NotImplementedError
> […]
> + def __init__(self, _time_fn=time.time):
> + """Initialize this class.
> +
> + @param _time_fn: Function used to return time (unittest only)
> +
> + """
> + CacheBase.__init__(self)
> +
> + self._time_fn = _time_fn
> +
> + self.cache = {}
> + self.lock = locking.SharedLock("SimpleCache-lock")
The “-lock” is superfluous.
> + self.last_cleanup = self._time_fn()
> […]
> + @locking.ssynchronized("lock")
Please put the lock name in a class-level constant:
class …:
_LOCK_ATTR = "lock"
@locking.ssynchronized(_LOCK_ATTR)
def …
Rest LGTM.
Michael