class CacheManager(object): def __init__(self, cfg): self._cfg = cfg self._prepare_directories() self._memoryCache = MemoryCache(self._cfg.memory_cache_lifetime) self._diskCache = disk_cache.DiskCache(self._cfg, self._memoryCache) @trace def getAttributes(self, path, pathToCache=False): memstat = self._memoryCache.getAttributes(path) if not memstat: if loclogger.debug: DEBUG("Checking cache directory for %s" % path) st = self._getAttributesFromDiskCache(path) self._memoryCache.cacheAttributes(path, st) memstat = self._memoryCache.getAttributes(path) return memstat.stat @trace def listDirectory(self, path): try: return self._memoryCache.listDirectory(path) except memory_cache.MemoryCacheNotValid, e: if loclogger.debug: DEBUG("Memory cache is not valid") return self._diskCache.listDirectory(path)
def __init__(self, cfg): self._cfg = cfg self._prepare_directories() self._memoryCache = MemoryCache(self._cfg.memory_cache_lifetime) self._diskCache = disk_cache.DiskCache(self._cfg, self._memoryCache)