Reputation: 521
I am using redis-queue gem to implement a message queue in redis server. Every single message undergoes the lpush and lpop command in the message queue. I am able to get the current length of the queue which is apparently a Redis list using the llen command.
But is there any single way I can get the total number of lpush as well as lpop happened on the list during a particular time span, say in the past 24 hrs. ?
Upvotes: 1
Views: 1044
Reputation: 49962
In addition to using keyspace notifications, as proposed by my esteemed SO peer Matias, there are at least two additional ways that you can do that:
The INFO COMMANDSTATS
prints, for each command, a wealth of information including a counter. To reset the instance's statistics, use CONFIG RESETSTAT
. Note that this does not offer per key counts but per command (which may be good enough, depending on the case).
You can MONITOR
a Redis instance to get a stream of all the commands it executes. Simple filtering can get you any statistic you're after, but note that using MONITOR
has a performance impact.
Upvotes: 1
Reputation: 64923
It seems like you can use Redis keyspace notifications for this. Redis can be activated to publish messages when keys are changed under certain conditions and then you can subscribe to this messages using regular Redis pubsub.
Upvotes: 2