INCR mykey
initiates to 0 and increments the value to 1. How would I set expiration time to the mykey
in the same command like it can be done with SETEX
?
Asked
Active
Viewed 1,648 times
1

Robert C. Holland
- 1,651
- 4
- 24
- 57
1 Answers
6
you can use pipeline or a lua script
in fact, in redis documentation, there is an example of implementing rate limit that needs to increase and set ttl using multi

Tuan Anh Tran
- 6,807
- 6
- 37
- 54
-
3Lua script is better, since it's atomic – for_stack Jan 06 '20 at 07:56