Reputation: 3739
Is it better to use namespaces to separate datasets or create a new database for each purpose?
Upvotes: 3
Views: 628
Reputation: 38899
It depends on your use case, but my rule of thumb is: If you have a very large quantity of related data keys that are unrelated to all the rest of your data in Redis, put them in a new database. Reasons being:
You may need to (non-ideally) use the keys
command to get all of that data at some point, and having the data segregated makes that much cheaper.
You may want to switch to a second redis server later, and having related data pre-segregated makes this much easier.
You can keep your databases named somewhere, so it's easier for you, or a new employee to figure out where to look for particular data.
Conversely, if your data is related to other data, they should always live in the same database, so you can easily write pipelines and lua scripts that can access both.
Upvotes: 2