redis-rb
redis-rb copied to clipboard
Redis.current.set returns different value after 4.1.1 (in test env with fakeredis)
I not sure is this exactly a bug in redis-rb or fakeredis, but starting from v.4.1.1 return value was changed as following:
v.4.1.0
p Redis.current.set("aaa", "aaa")
# "OK"
p Redis.current.set("aaa", "aaa", nx: true)
# false
v.4.1.1 only in test env with fakeredis (in dev env with normal redis returns false)
p Redis.current.set("aaa", "aaa")
# "OK"
p Redis.current.set("aaa", "aaa", nx: true)
# 0
redis-rb 4.1.0
BoolifySet =
lambda { |value|
if value && "OK" == value
true
else
false
end
}
redis-rb 4.1.1
BoolifySet = lambda { |value|
case value
when "OK"
true
when nil
false
else
value
end
}
The version 4.1.1 works fine with real Redis. I'd say that fakeredis might want to adjust to real Redis reply.
https://redis.io/commands/set
Simple string reply: OK if SET was executed correctly. Null reply: a Null Bulk Reply is returned if the SET operation was not performed because the user specified the NX or XX option but the condition was not met.
$ telnet 127.0.0.1 6381
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
set foo bar
+OK
set foo bar nx
$-1
Seems like a bug in fakeredis