Beispiel #1
0
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()
Beispiel #2
0
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()
Beispiel #3
0
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()
Beispiel #4
0
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()
Beispiel #5
0
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"已刷新缓存")
Beispiel #6
0
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"已刷新缓存")
Beispiel #7
0
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()
Beispiel #8
0
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
Beispiel #9
0
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
Beispiel #10
0
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
Beispiel #11
0
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
Beispiel #12
0
    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()
Beispiel #14
0
 def update_all_cache(self):
     from beaker.cache import cache_managers
     for _cache in cache_managers.values():
         _cache.clear()
Beispiel #15
0
 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)
Beispiel #16
0
 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)
Beispiel #17
0
 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)
Beispiel #18
0
def clear_cache():
    for _cache in cache_managers.values():
        _cache.clear()
Beispiel #19
0
 def update_all_cache(self):
     from beaker.cache import cache_managers
     for _cache in cache_managers.values():
         _cache.clear()
Beispiel #20
0
 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 get_cache_key_count(self):
     count = 0
     for cache_region in cache_managers.values():
         count += len(cache_region.namespace.dictionary.keys())
     return count
Beispiel #22
0
 def get(self):
     for _cache in cache_managers.values():
         _cache.clear()
     return self.render_json(code=0, msg=u"已刷新缓存")
Beispiel #23
0
 def invalidate_images_cache():
     for manager in cache_managers.values():
         if '_get_images_cache' in manager.namespace.namespace:
             manager.clear()
Beispiel #24
0
 def invalidate_images_cache():
     for manager in cache_managers.values():
         if '_get_images_cache' in manager.namespace.namespace:
             manager.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
Beispiel #26
0
 def get(self):
     for _cache in cache_managers.values():
         _cache.clear()
     return self.render_json(code=0, msg=u"已刷新缓存")
def clear_cache():
    """
    Clear all cache
    """
    for _cache in cache_managers.values():
        _cache.clear()
Beispiel #28
0
 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()
Beispiel #29
0
def clear_all_caches():
    from beaker.cache import cache_managers
    for _cache in cache_managers.values():
        _cache.clear()
Beispiel #30
0
 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()
Beispiel #31
0
# 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()