Search code examples
goredisredigo

Redis how to listen changes in 1000 to 10,000 lists using golang?


I have 1000 to 10,000 keys stored in Redis, their value type is list. When a new item is added to any one of the existing lists, I need my golang program to be notified. Once notification is received I need to spawn a new goroutine and perform a small operation.

I am using redigo for redis connection pool.

What is the best approach to solve this problem, without overloading the Redis instance?


Solution

  • You can enable Redis' keyspace notifications and subscribe to the relevant events on the keys/patterns that interest you.

    More details can be found in the documentation: http://redis.io/topics/notifications