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 id_by_b64(cls, session): id, binary = _id_binary_decode(session) if id: key = R_SESSION % id id = int(id) if id and binary and binary == redis.get(key): return id
def id_by_b64(cls, session): id, binary = _id_binary_decode(session) if id: key = R_SESSION%id id = int(id) if id and binary and binary == redis.get(key): return id
def id_by_b64(cls, session): user_id, binary = _id_binary_decode(session) if user_id: key = R_SESSION % user_id user_id = int(user_id) if user_id and binary and binary == redis.get(key): return user_id
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 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 _get_cache(self, key): key = self.CACHE%key r = redis.get(key) if r is not None: t = array('I') t.fromstring(r) else: t = None return t
def id_score_list_by_user_id(user_id): key = REDIS_REC_USER_TAG_CAN_REC%user_id result = redis.get(key) if result is None: key_tag = REDIS_REC_USER_TAG%user_id if redis.exists(key_tag): #第一次初始化 result = redis.zrevrange(key_tag, 0, REDIS_REC_USER_TAG_LIMIT-1, True) id_score_list_new(user_id, result) else: result = None else: result = loads_id_score(result) return result
def get(cls, user_id): key = R_SESSION % user_id return redis.get(key)
def get(cls, user_id): key = R_SESSION%user_id return redis.get(key)
def captcha_verify(key, token): if token and (token.lower() == redis.get(R_CAPTCHA % key)): captcha_rm(key) return True return False