def invalidate(): """Kill all the caches. Used after major updates to depended data, like the card list.""" from beaker.cache import cache_managers for _cache in cache_managers.values(): _cache.clear()
def invalidate_all_caches(): """invalidates all cache values. Based on: http://stackoverflow.com/a/14251064/3259351 """ from beaker.cache import cache_managers for _cache in cache_managers.values(): _cache.clear()
def cache_flush_data(): logger.info("flush cache for data") for namespace_name in cache_managers.values(): ''' flush all cache except session ''' if 'edware_session' != namespace_name.namespace_name[:14]: namespace_name.clear()
def clear_cache(db,render): def cbk(resp): print 'cbk',resp bottle.TEMPLATES.clear() for _cache in cache_managers.values(): _cache.clear() websock.update_cache("all",callback=cbk) return dict(code=0,msg=u"已刷新缓存")
def clear_cache(): def cbk(resp): print 'cbk',resp bottle.TEMPLATES.clear() for _cache in cache_managers.values(): _cache.clear() websock.update_cache("all",callback=cbk) return dict(code=0,msg=u"已刷新缓存")
def invalidate_all_caches(): """Invalidate all beaker caches currently configured. Useful when manipulating IP permissions in a test and changes need to take effect immediately. Note: Any use of this function is probably a workaround - it should be replaced with a more specific cache invalidation in code or test.""" from beaker.cache import cache_managers for cache in cache_managers.values(): cache.clear()
def cache_flush_session(): ''' flush cache for session ''' logger.info("flush cache for session") for namespace_name in cache_managers.values(): ''' flush session cache ''' if 'edware_session' == namespace_name.namespace_name[:14]: namespace_name.clear() break
def clear_cache(name=None): """ Clear all cache from beaker :param name: Cache name to be clared :return: True """ for _cache in cache_managers.values(): if name is not None and _cache == name: # Clear only this cache _cache.clear() break _cache.clear() return True
def after_update(self, context, pkg_dict): """ If this is the specimen resource, clear memcached NB: Our version of ckan doesn't have the IResource after_update method But updating a resource calls IPackageController.after_update @param context: @param resource: @return: """ for resource in pkg_dict.get('resources', []): # If this is the specimen resource ID, clear the collection stats if 'id' in resource: if resource['id'] in [helpers.get_specimen_resource_id(), helpers.get_indexlot_resource_id()]: # Quick and dirty, delete all caches when indexlot or specimens are updated # TODO: Move to invalidate_cache - need to investigate why that isn't working for _cache in cache_managers.values(): _cache.clear()
def after_update(self, context, pkg_dict): """ If this is the specimen resource, clear memcached NB: Our version of ckan doesn't have the IResource after_update method But updating a resource calls IPackageController.after_update @param context: @param resource: @return: """ for resource in pkg_dict.get('resources', []): # If this is the specimen resource ID, clear the collection stats if 'id' in resource: if resource['id'] in [helpers.get_specimen_resource_id(), helpers.get_indexlot_resource_id()]: log.info('Clearing caches') # Quick and dirty, delete all caches when indexlot or specimens are updated for _cache in cache_managers.values(): _cache.clear() # Clear the NGINX proxy cache cache_clear_nginx_proxy()
def update_all_cache(self): from beaker.cache import cache_managers for _cache in cache_managers.values(): _cache.clear()
def validate_cache_has_expected_number_of_item(self, expected): self.assertTrue(len(cache_managers.keys()), 1) for cache_region in cache_managers.values(): self.assertEqual(len(cache_region.namespace.dictionary.keys()), expected)
def validate_cache_is_empty(self): self.assertTrue(len(cache_managers.keys()), 1) for cache_region in cache_managers.values(): self.assertEqual(len(cache_region.namespace.dictionary.keys()), 0)
def clear_cache(): for _cache in cache_managers.values(): _cache.clear()
def get_cache_key_count(self): count = 0 for cache_region in cache_managers.values(): count += len(cache_region.namespace.dictionary.keys()) return count
def get(self): for _cache in cache_managers.values(): _cache.clear() return self.render_json(code=0, msg=u"已刷新缓存")
def invalidate_images_cache(): for manager in cache_managers.values(): if '_get_images_cache' in manager.namespace.namespace: manager.clear()
def clear_cache(): """ Clear all cache """ for _cache in cache_managers.values(): _cache.clear()
def invalidate_connection_cache(): """Empty connection objects cache""" for manager in cache_managers.values(): namespace = manager.namespace.namespace if '_aws_connection' in namespace or '_euca_connection' in namespace: manager.clear()
def clear_all_caches(): from beaker.cache import cache_managers for _cache in cache_managers.values(): _cache.clear()
# How can you refresh all regions in Beaker cache in Pyramid? from beaker.cache import cache_managers for _cache in cache_managers.values(): _cache.clear()