Set password value and expiration atomically
Redis has a `SETEX` (http://redis.io/commands/SETEX) method, which does both setting the value and setting the expiration atomically.
This commit is contained in:
parent
d12a090952
commit
9e89376416
1 changed files with 1 additions and 2 deletions
|
@ -48,8 +48,7 @@ def check_redis_alive(fn):
|
|||
@check_redis_alive
|
||||
def set_password(password, ttl):
|
||||
key = uuid.uuid4().hex
|
||||
redis_client.set(key, password)
|
||||
redis_client.expire(key, ttl)
|
||||
redis_client.setex(key, ttl, password)
|
||||
return key
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue