예제 #1
0
def db_flush_cache(data_descriptor):
    cached_key = make_cached_key(data_descriptor.getSchema(),
                                 data_descriptor.getDataType(),
                                 data_descriptor.getKeys())
    cache = None

    cache_time = get_cache_policy(data_descriptor.getSchema(),
                                  data_descriptor.getDataType())
    if cache_time is None or cache_time < 0:
        cache_time = 0

    cache = Cache_Service() if not cache_time == 0 else None

    try:
        if cache is not None and cache.exists(cached_key):
            cache.delete(cached_key)
    except Exception, e:
        import traceback
        logger.error("exception from redis:\n %s" % traceback.format_exc())
예제 #2
0
def db_flush_cache(data_descriptor):
    cached_key = make_cached_key(data_descriptor.getSchema(),
                                 data_descriptor.getDataType(),
                                 data_descriptor.getKeys())
    cache = None

    cache_time = get_cache_policy(data_descriptor.getSchema(),
                                   data_descriptor.getDataType())
    if cache_time is None or cache_time < 0:
        cache_time = 0

    cache = Cache_Service() if not cache_time == 0 else None
    
    try:
        if cache is not None and cache.exists(cached_key):
            cache.delete(cached_key)
    except Exception, e:
        import traceback
        logger.error("exception from redis:\n %s"%traceback.format_exc())
예제 #3
0
def db_get(data_descriptor, session=None):
    cached_key = make_cached_key(data_descriptor.getSchema(),
                                 data_descriptor.getDataType(),
                                 data_descriptor.getKeys())
    cache = None
    # cache_time = 0 measn the cache will not timeout
    cache_time = get_cache_policy(data_descriptor.getSchema(),
                                   data_descriptor.getDataType())
    logger.debug ("configured cache_time is %s, cached_key is %s"%(cache_time, cached_key))
    if cache_time < 0:
        cache_time = None

    cache = Cache_Service() if cache_time is not None else None

    try:
        if cache is not None and cache.exists(cached_key):
            return cache.get(cached_key)
    except Exception, e:
        import traceback
        logger.error("exception from redis:\n %s"%traceback.format_exc())
예제 #4
0
def db_get(data_descriptor, session=None):
    cached_key = make_cached_key(data_descriptor.getSchema(),
                                 data_descriptor.getDataType(),
                                 data_descriptor.getKeys())
    cache = None
    # cache_time = 0 measn the cache will not timeout
    cache_time = get_cache_policy(data_descriptor.getSchema(),
                                  data_descriptor.getDataType())
    logger.debug("configured cache_time is %s, cached_key is %s" %
                 (cache_time, cached_key))
    if cache_time < 0:
        cache_time = None

    cache = Cache_Service() if cache_time is not None else None

    try:
        if cache is not None and cache.exists(cached_key):
            return cache.get(cached_key)
    except Exception, e:
        import traceback
        logger.error("exception from redis:\n %s" % traceback.format_exc())