The SET command has an option to ad EX and set expire. Why not add that to INCR?

Comment From: badboy

Because the use-case didn't come up yet (personally I'm against overloading even more commands with crude expire syntax, doesn't make clients easier at all). Meanwhile, he same can be achieved using a transaction instead.

Comment From: mperkel

I understand. But both SET and INCR create variables that don't exist. Seems like an easy fix that would save me having to use 2 commands instead of one.

Comment From: adam-meya

I think this is valuable as it would simplify creating rate limited APIs, a very common pattern. Right now it is tempting to do it the wrong way because it is cleaner.

Comment From: rfyiamcool

Please pipeline .

Comment From: TrejGun

MULTI
INCR yourkey
EXPIRE yourkey 100
EXEC

Comment From: dpep

the issue with multi is that technically it's possible that your key will expire after the INCR and before the EXPIRE - it's atomic in relation to other user commands, but not system work like garbage collection

Comment From: rodriguez-facundo

vote for the flag in incr :)

Adding MULTI from a lua script is awkward

Comment From: cnxh

you can use set with ex & nx

MULTI
SET yourkey 0 ex 3600 nx
INCR yourkey
EXEC

Comment From: realshovanshah

It's been more than 5 years wow. It'd be good to get an update or a green light on this for anyone interested in opening a PR.

Comment From: RandyLambert

Our company often uses this feature. If I add Expiration Setting to Incr/DECR, will it have the opportunity to merge to the Redis main branch?

Comment From: maddsua

Because the use-case didn't come up yet

This must be a joke. Have you guys never implemented a rate limiter? One of the most basic implementations of it is literally that