Beispiel #1
0
 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)
Beispiel #2
0
 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)
Beispiel #3
0
 def _set_cache(self, key, id_list):
     key = self.CACHE%key
     result = array('I')
     result.fromlist(id_list)
     redis.setex(
         key, result.tostring(), EXPIRE
     )
Beispiel #4
0
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
Beispiel #5
0
 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)
Beispiel #7
0
def captcha_new():
    token, b64img = captcha()
    key = b64uuid()
    redis.setex(R_CAPTCHA % key, 3600 * 3, token.lower())
    return key, token, b64img