class CreateCache: def __init__(self): self.database = Database(redis_conf=REDISEVER, password=STATUS_REDIS_PASS) def getCreateDetail(self, cid): try: res = self.database.getCreateInfo(cid) if not res: return None else: return json.loads(res) except Exception, e: logger.error(e)
class CreateCache(): def __init__(self): self.database = Database(redis_conf = CONFIG_REDISEVER, password = STATUS_REDIS_PASS) self.cache = defaultdict() def getCreateDetail(self, cid): try: if self.cache.has_key(cid): return self.cache[cid] else: res = self.database.getCreateInfo(cid) if not res: return None else: cid_detail = json.loads(res) self.cache[cid] = cid_detail return cid_detail except Exception,e: logger.error(e)