Closed letientai299 closed 3 weeks ago
I'm using keyspace notification in redis. Let's say the key I'm interesting in the key-space event of testkey
testkey
With redis-cli, I can use PSUBSCRIBE with the pattern _keyspace@*__:testkey successfully.
PSUBSCRIBE
_keyspace@*__:testkey
127.0.0.1:6379> PSUBSCRIBE __keyspace@*__:testkey Reading messages... (press Ctrl-C to quit) 1) "psubscribe" 2) "__keyspace@*__:testkey" 3) (integer) 1 1) "pmessage" 2) "__keyspace@*__:testkey" 3) "__keyspace@0__:testkey" 4) "set" 1) "pmessage" 2) "__keyspace@*__:testkey" 3) "__keyspace@0__:testkey" 4) "set"
But in go, the above pattern following pattern won't work. Here's code sample
subPattern := "__keyspace@*__:testkey" sub := a.redisClient.PSubscribe(subPattern) log.Printf("watching %v", subPattern) //lastScore := util.TimeNowMillis() for { msg, err := sub.Receive() if err != nil { log.Println(err) continue } log.Println(msg) //switch msg.(type) { }
But this pattern __keyspace@*__:testkey*, with a wildcard suffix, works.
__keyspace@*__:testkey*
I've tested and see that this issue happen with both redis single instance and in cluster mode. I've tested this with other golang redis lib yet.
Is this an expected behaviors? If so, may I have a link to read more about keyspace patterns?
try enabling notify keyspace events first using config set
rdb.ConfigSet(ctx, "notify-keyspace-events", "KEA")
This issue is marked stale. It will be closed in 30 days if it is not updated.
I'm using keyspace notification in redis. Let's say the key I'm interesting in the key-space event of
testkey
With redis-cli, I can use
PSUBSCRIBE
with the pattern_keyspace@*__:testkey
successfully.But in go, the above pattern following pattern won't work. Here's code sample
But this pattern
__keyspace@*__:testkey*
, with a wildcard suffix, works.I've tested and see that this issue happen with both redis single instance and in cluster mode. I've tested this with other golang redis lib yet.
Is this an expected behaviors? If so, may I have a link to read more about keyspace patterns?