At 9.18.0, by #3673, cmdable.SetNX is marked as deprecated (along with other old commands).
The deprecation notice says Use Set with NX option instead as of Redis 2.6.12.. But in go-redis, SetNX is provided as BoolCmd but Set is as StatusCmd, so they are not equivalent.
Especially my codebase uses SetNX to acquire lock, like lockAcquired, err := rdb.SetNX(...) , so changing it to cmdable.Set is not straight-forward.
(In contrast, cmdable.SetEx, which is also deprecated in #3673 , is perfectly safe to deprecate since it's interface is same as cmdable.Set)
Expected Behavior
There're (convenient) ways to use SET NX operation as BoolCmd
Current Behavior
SetNX is deprecated, and Set is StatusCmd and is not BoolCmd
Possible Solution
No idea?
For me un-deprecate cmdable.SetNX seems fine.
Additionally, by removing old setnx fallback, it will be "clean" since it will not use old redis commands anymore.
|
case 0: |
|
// Use old `SETNX` to support old Redis versions. |
|
cmd = NewBoolCmd(ctx, "setnx", key, value) |
But, if you'd like remove cmdable.SetNX itself in future, maybe it's not good one.
Steps to Reproduce
Context (Environment)
Detailed Description
Possible Implementation
At 9.18.0, by #3673,
cmdable.SetNXis marked as deprecated (along with other old commands).The deprecation notice says
Use Set with NX option instead as of Redis 2.6.12.. But in go-redis,SetNXis provided as BoolCmd butSetis as StatusCmd, so they are not equivalent.Especially my codebase uses SetNX to acquire lock, like
lockAcquired, err := rdb.SetNX(...), so changing it tocmdable.Setis not straight-forward.(In contrast,
cmdable.SetEx, which is also deprecated in #3673 , is perfectly safe to deprecate since it's interface is same ascmdable.Set)Expected Behavior
There're (convenient) ways to use
SET NXoperation as BoolCmdCurrent Behavior
SetNX is deprecated, and Set is StatusCmd and is not BoolCmd
Possible Solution
No idea?
For me un-deprecate cmdable.SetNX seems fine.
Additionally, by removing old
setnxfallback, it will be "clean" since it will not use old redis commands anymore.go-redis/string_commands.go
Lines 440 to 442 in 90faf06
But, if you'd like remove
cmdable.SetNXitself in future, maybe it's not good one.Steps to Reproduce
Context (Environment)
Detailed Description
Possible Implementation