miniredis
miniredis copied to clipboard
not support setnx with ttl?
not support setnx with ttl? (Issue #259)
Hi,
thank you for opening an issue.
I don't understand what you're asking. Can you point to the documentation on the redis.io site? Maybe somewhere here: https://redis.io/commands/setnx
Thanks!
I might understand what @g10guang means. Checking FastForward
should be helpful
use "github.com/gomodule/redigo/redis exec redis command Do("SET", "key", "value", "PX", int64(expire), "nx")
expire not work. but using a physical Redis server is ok
Playground: https://go.dev/play/p/2VEvoPXkQLc
Thanks for the clarification. That's what @ChaosNyaruko was going for, please check https://github.com/alicebob/miniredis#ttls-key-expiration-and-time
Thanks for the clarification. That's what @ChaosNyaruko was going for, please check https://github.com/alicebob/miniredis#ttls-key-expiration-and-time
go playground code example address: https://go.dev/play/p/gUMLoDvHRU7
I called the function FastForward. TTL is decrease when TTL is equal 0, exec command "Do("SET", "key", "value", "PX", int64(expire), "nx")" miniredis reply is not ok
Hi,
thanks for your clarification.
You use: redis.FastForward(1)
, which is 1 nanosecond.
It works if you use this:
// time.Sleep(time.Second * 1)
mockRedis.FastForward(1 * time.Second)
That gives me:
start
ttl1 1 ttl2 -2
(note that you don't need to call time.Sleep())
☕️。 thanks