app/soc/cache/home.py
changeset 2365 a66e1dd8ced7
parent 2160 3f9dd37d98a8
child 2409 5ffa2372f1d6
equal deleted inserted replaced
2364:a1cbd3143277 2365:a66e1dd8ced7
    54   if not entity:
    54   if not entity:
    55     return (None, None)
    55     return (None, None)
    56 
    56 
    57   memcache_key = key(entity)
    57   memcache_key = key(entity)
    58   logging.info("Retrieving %s" % memcache_key)
    58   logging.info("Retrieving %s" % memcache_key)
       
    59   # pylint: disable-msg=E1101
    59   return memcache.get(memcache_key), memcache_key
    60   return memcache.get(memcache_key), memcache_key
    60 
    61 
    61 def put(result, memcache_key, *args, **kwargs):
    62 def put(result, memcache_key, *args, **kwargs):
    62   """Sets the sidebar for the specified user in the memcache.
    63   """Sets the sidebar for the specified user in the memcache.
    63 
    64 
    72 
    73 
    73   # Store sidebar for just ten minutes to force a refresh every so often
    74   # Store sidebar for just ten minutes to force a refresh every so often
    74   retention = 10*60
    75   retention = 10*60
    75 
    76 
    76   logging.info("Setting %s" % memcache_key)
    77   logging.info("Setting %s" % memcache_key)
       
    78   # pylint: disable-msg=E1101
    77   memcache.add(memcache_key, result, retention)
    79   memcache.add(memcache_key, result, retention)
    78 
    80 
    79 
    81 
    80 def flush(entity):
    82 def flush(entity):
    81   """Removes the sidebar for the current user from the memcache.
    83   """Removes the sidebar for the current user from the memcache.
    86     id: defaults to the current account if not set
    88     id: defaults to the current account if not set
    87   """
    89   """
    88 
    90 
    89   memcache_key = key(entity)
    91   memcache_key = key(entity)
    90   logging.info("Flushing %s" % memcache_key)
    92   logging.info("Flushing %s" % memcache_key)
       
    93   # pylint: disable-msg=E1101
    91   memcache.delete(memcache_key)
    94   memcache.delete(memcache_key)
    92 
    95 
    93 
    96 
    94 # define the cache function
    97 # define the cache function
    95 cache = soc.cache.base.getCacher(get, put)
    98 cache = soc.cache.base.getCacher(get, put)