app/soc/cache/logic.py
changeset 2365 a66e1dd8ced7
parent 2187 e4172c7792f5
equal deleted inserted replaced
2364:a1cbd3143277 2365:a66e1dd8ced7
    51 def get(model, filter, order, *args, **kwargs):
    51 def get(model, filter, order, *args, **kwargs):
    52   """Retrieves the data for the specified query from the memcache.
    52   """Retrieves the data for the specified query from the memcache.
    53   """
    53   """
    54 
    54 
    55   memcache_key = key(model, filter, order)
    55   memcache_key = key(model, filter, order)
       
    56   # pylint: disable-msg=E1101
    56   return memcache.get(memcache_key), memcache_key
    57   return memcache.get(memcache_key), memcache_key
    57 
    58 
    58 
    59 
    59 def put(data, memcache_key, *args, **kwargs):
    60 def put(data, memcache_key, *args, **kwargs):
    60   """Sets the data for the specified query in the memcache.
    61   """Sets the data for the specified query in the memcache.
    63     data: the data to be cached
    64     data: the data to be cached
    64   """
    65   """
    65 
    66 
    66   # Store data for fifteen minutes to force a refresh every so often
    67   # Store data for fifteen minutes to force a refresh every so often
    67   retention = 15*60
    68   retention = 15*60
       
    69   # pylint: disable-msg=E1101
    68   memcache.add(memcache_key, data, retention)
    70   memcache.add(memcache_key, data, retention)
    69 
    71 
    70 
    72 
    71 def flush(model, filter):
    73 def flush(model, filter):
    72   """Removes the data for the current user from the memcache.
    74   """Removes the data for the current user from the memcache.
    73   """
    75   """
    74 
    76 
    75   memcache_key = key(model, filter)
    77   memcache_key = key(model, filter)
       
    78   # pylint: disable-msg=E1101
    76   memcache.delete(memcache_key)
    79   memcache.delete(memcache_key)
    77 
    80 
    78 
    81 
    79 # define the cache function
    82 # define the cache function
    80 cache = soc.cache.base.getCacher(get, put)
    83 cache = soc.cache.base.getCacher(get, put)