Am 10. Juni 2011 14:04 schrieb René Nussbaumer <[email protected]>:
> --- /dev/null
> +++ b/lib/cache.py
> +_cache = None
> +_cache_lock = threading.Lock()
Why a singleton? Can't you just keep the instance in GanetiContext?
> +
> +TIMESTAMP = "timestamp"
> +TTL = "ttl"
> +VALUE = "value"
Please make these private (“_…”).
> +class SimpleCache(CacheBase):
> + def _UnlockedInvalidate(self, keys):
> + """Invalidate keys in cache.
> +
> + This is the unlocked version, see L{Invalidate} for parameter description
> +
> + """
> + for key in keys:
> + if key in self.cache:
> + del self.cache[key]
Since it's a dict: self.cache.pop(key, None). Saves you from a second lookup.
Michael