1

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 ?

Robert C. Holland
  • 1,651
  • 4
  • 24
  • 57

1 Answers1

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

https://redis.io/commands/INCR

Tuan Anh Tran
  • 6,807
  • 6
  • 37
  • 54