fbf cache provding get, set and delete functions.
delete data from the cache.
get data from the cache.
set data in the cache.
# fbf/cache.py # # """ fbf cache provding get, set and delete functions. """
from fbf.utils.lazydict import LazyDict
import logging
cache = LazyDict()
def get(name, namespace=""): """ get data from the cache. """ global cache try: #logging.debug("cache - returning %s" % cache[name]) return cache[name] except KeyError: pass def set(name, item, timeout=0, namespace=""): """ set data in the cache. """ #logging.debug("cache - setting %s to %s" % (name, str(item))) global cache cache[name] = item def delete(name, namespace=""): """ delete data from the cache. """ try: global cache del cache[name] logging.warn("cache - deleted %s" % name) return True except KeyError: return False def size(): return len(cache)