Reputation: 21
Now,I have a redis conn named r
, and two hash table named: hash1
, hash2
.
Then
r.hset(hash1, id, value1)
r.hset(hash2, id, value2)
r.expire(id, ttl)
is that valid use? or it's error?
Upvotes: 1
Views: 775
Reputation: 1857
Expire function is not available on hash fields. In the official documentation (picture below) you can find the functions that apply for a hash key.
There exist topics discussion the absence of the expire functionality within a hash. Take a look at this one for example: https://github.com/antirez/redis/issues/3192
You can however manage the deletion yourself using HDEL or some cron task if you have a deletion timeout for all keys. I understand that this is not ideal indeed :-)
Upvotes: 1