lua-resty-redis icon indicating copy to clipboard operation
lua-resty-redis copied to clipboard

Set key by expiration time

Open ghost opened this issue 6 years ago • 7 comments
trafficstars

How can I set a record in Redis by the expiration time?

ghost avatar Jul 14 '19 08:07 ghost

Any update regarding this topic?

soufiane-fadil avatar Jul 25 '19 16:07 soufiane-fadil

You can use redisInstance.setex(key, ttl, value). I'm used to a library where i can set with ttl as param, totally forgot 💃

soufiane-fadil avatar Jul 25 '19 16:07 soufiane-fadil

You close this issue.

soufiane-fadil avatar Jul 25 '19 16:07 soufiane-fadil

red:set() red:expire()

Lorryrui avatar Oct 23 '19 09:10 Lorryrui

With red:expire(10) the key was still set to -1 (infinite) in the database.

dromer avatar Nov 12 '19 15:11 dromer

setting red:expire(key,ttl) works for me and it is setting valid ttl in the redis databse.

vasuharish avatar Mar 20 '20 04:03 vasuharish

^ yup, can confirm that red:expire(key, ttl) works!

dromer avatar Dec 08 '20 12:12 dromer