Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to monitor only one database?

Tags:

redis

Currently, my understanding is that the 'monitor' command outputs all commands received by the server, no matter which database number they are sent to.

This is a problem for me as I use one db for holding 'normal' data and one db for holding session data, and the output from the session db makes it near impossible to read the output from the other db.

Is there a way to limit the output to only one database ?

like image 619
Running Turtle Avatar asked Sep 08 '11 13:09

Running Turtle


2 Answers

What about this?

redis-cli monitor |grep '(db 1)'

That way you would just get the output of DB 1

like image 97
Matthias Scholz Avatar answered Oct 25 '22 18:10

Matthias Scholz


Databases in redis are not at all like databases in SQL. They are essentially just a predefined key prefix with no configuration of their own.

If you only want to see changes to the real data, you will need to set it up as a separate instance so that session data goes to a different process.

There isn't much overhead in doing this (in most scenarios it will actually improve performance) and there are other good reasons for using multiple instances. For example you probably want your real data written to disk in real time and backed up, but session data is worthless after a server restart so doesn't need to be saved to disk at all. With a shared instance you would have to save and back up everything, which isn't particularly good for performance with session data changing much more than permanent data.

like image 42
Tom Clarkson Avatar answered Oct 25 '22 18:10

Tom Clarkson