예제 #1
0
파일: cache.py 프로젝트: abelenki/reppiced
	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
예제 #2
0
파일: cache.py 프로젝트: abelenki/reppiced
    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
예제 #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    
예제 #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