def new(cls, user_id, expire=SESSION_EXPIRE * 3600 * 24): user_id = int(user_id) if user_id: key = R_SESSION % user_id s = redis.get(key) or urandom(12) redis.setex(key, expire, s) return _id_binary_encode(user_id, s)
def new(cls, id, expire=SESSION_EXPIRE * 3600 * 24): id = int(float(id)) if id: key = R_SESSION % id s = redis.get(key) or urandom(12) redis.setex(key, expire, s) return _id_binary_encode(id, s)
def _set_cache(self, key, id_list): key = self.CACHE%key result = array('I') result.fromlist(id_list) redis.setex( key, result.tostring(), EXPIRE )
def id_score_list_by_hot(): result = redis.get(REDIS_REC_TAG_ID_SCORE) if result is None: result = redis.zrevrange(REDIS_REC_TAG, 0, REDIS_REC_USER_TAG_LIMIT-1, True) result = [map(int, i) for i in result] redis.setex(REDIS_REC_TAG_ID_SCORE, dumps_id_score(result), ONE_DAY) else: result = loads_id_score(result) return result
def set(cls, id, session, expire=EXPIRE_DAY * 3600 * 24): key = R_SESSION % id redis.setex(key, expire, session) return cls.encode(id, session)
def set(cls, id, session, expire=EXPIRE_DAY*3600*24): key = R_SESSION%id redis.setex(key, expire, session) return cls.encode(id, session)
def captcha_new(): token, b64img = captcha() key = b64uuid() redis.setex(R_CAPTCHA % key, 3600 * 3, token.lower()) return key, token, b64img