While browsing Redis command reference, I came across two very similar comands:
SET with EX option: https://redis.io/commands/setSETEX: https://redis.io/commands/setexThe SETEX boasts itself as an atomic way to do SET and EXPIRE, yet by the looks of it the same thing can be achieved with SET EX as it's also a single command.
SETEX was added in 2.0.0, while EX parameter was added in 2.6.12, so it seems that the former remains for the backwards compatibility, but for some reason it's not marked as deprecated.
Did I miss anything? Are there any valid cases for using SETEX nowadays?
The SET documentation says:
Note: Since the SET command options can replace SETNX, SETEX, PSETEX, it is possible that in future versions of Redis these three commands will be deprecated and finally removed.
So it's safe to say that there's no reason to use SETEX if you have Redis version 2.6.12 or higher.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With