Beispiel #1
0
	def cachedQuery(self, kind, **kwargs):
		update = kwargs.pop('_update', None)
		key = make_key(kind, **kwargs)
		res = self.get(key)
		
		if not res or update:
			res = Transaction(kind).query(**kwargs)
			self.updatecache(key, res, True)
		return None if type(res) == type(NoneResult) else res
Beispiel #2
0
    def cachedQuery(self, kind, **kwargs):
        update = kwargs.pop('_update', None)
        key = make_key(kind, **kwargs)
        res = self.get(key)

        if not res or update:
            res = Transaction(kind).query(**kwargs)
            self.updatecache(key, res, True)
        return None if type(res) == type(NoneResult) else res
Beispiel #3
0
 def set(kind, key, value, **kwargs):
     hkey = make_key(kind, key, **kwargs)
     if len(CACHE) >= 100:           #
         t = CACHE_KEYS[0]
         del CACHE_KEYS[0]
         CACHE.pop(t, None)
     CACHE[hkey] = value
     if hkey in CACHE_KEYS:
         del CACHE_KEYS[CACHE_KEYS.index(hkey)]
     CACHE_KEYS.append(hkey)
     memcache.set(hkey, value, STALE)
     return True    
Beispiel #4
0
 def get(kind, key, **kwargs):
     hkey = make_key(kind, key, **kwargs)
     if hkey in CACHE:
         return CACHE[hkey]
     res = memcache.get(hkey)
     return res