I want to store the following hash map in redis:
"data": {
"name": "XYZ",
"age": 22,
"address": "a-z"
}
I want this whole hash map (with the given key) to expire in time, let's say 72 hours.
How do I use ttl/expire
function in python?
Thanks,
Following is what I want to do, I guess it is right:
def put_data(name=hash_name, key=hash_key, value=hash_data):
import redis
r = Redis.get_connection()
ttl = datetime.today() + timedelta(hours=72)
r.hset(name=name, key=hash_key, value=hash_data)
r.expire(name=hash_name, time=ttl)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.