def cacheClear(self, params): before = cache_util.cachesInfo() cache_util.cachesClear() after = cache_util.cachesInfo() return { 'cacheCleared': datetime.datetime.utcnow(), 'before': before, 'after': after }
def testCachesClear(self): large_image.cache_util.cache._tileCache = None large_image.cache_util.cache._tileLock = None config.setConfig('cache_backend', 'python') self.ExampleWithMetaclass('test') getTileCache() assert cachesInfo()['test']['used'] == 1 cachesClear() assert cachesInfo()['test']['used'] == 0
def testCachesKeyLock(self): cachesClear() assert cachesInfo()['test']['used'] == 0 starttime = time.time() with concurrent.futures.ThreadPoolExecutor(max_workers=3) as executor: executor.map(self.ExampleWithMetaclass, [3, 3, 2]) endtime = time.time() # This really should be close to 3 assert endtime - starttime < 6 assert cachesInfo()['test']['used'] == 2
def cacheClear(self, params): before = cache_util.cachesInfo() cache_util.cachesClear() after = cache_util.cachesInfo() # Add a small delay to give the memcached time to clear stoptime = time.time() + 5 while time.time() < stoptime and any(after[key]['used'] for key in after): time.sleep(0.1) after = cache_util.cachesInfo() return {'cacheCleared': datetime.datetime.utcnow(), 'before': before, 'after': after}
def testCachesInfo(self): large_image.cache_util.cache._tileCache = None large_image.cache_util.cache._tileLock = None assert cachesInfo()['test']['used'] == 0 assert 'tileCache' not in cachesInfo() self.ExampleWithMetaclass('test') assert cachesInfo()['test']['used'] == 1 config.setConfig('cache_backend', 'python') getTileCache() assert 'tileCache' in cachesInfo() large_image.cache_util.cache._tileCache = None large_image.cache_util.cache._tileLock = None config.setConfig('cache_backend', 'memcached') getTileCache() # memcached won't show that it is present assert 'tileCache' not in cachesInfo()
def testCachesInfo(self): cachesClear() large_image.cache_util.cache._tileCache = None large_image.cache_util.cache._tileLock = None assert cachesInfo()['test']['used'] == 0 assert 'tileCache' not in cachesInfo() self.ExampleWithMetaclass('test') assert cachesInfo()['test']['used'] == 1 config.setConfig('cache_backend', 'python') getTileCache() assert 'tileCache' in cachesInfo() large_image.cache_util.cache._tileCache = None large_image.cache_util.cache._tileLock = None config.setConfig('cache_backend', 'memcached') getTileCache() # memcached shows an items record as well assert 'items' in cachesInfo()['tileCache']
def cacheInfo(self, params): return cache_util.cachesInfo()