One Redis trick that restored my sanity (but probably won't work on you)

I’m in the process of merging my two €1/month VPSes to save that €1/month, and what’s pretty mad about this is I’m migrating apps from the more used server onto the less used one (because that’s the order in which the money’s gonna get pulled).

But perhaps one of the most annoying things about it is how I run as many things as possible on one server without too much isolation. That doesn’t mess up my thinking when it comes to databases like Postgres, because I can just add a named database, say nyuuu or nnnnnnaas (this one doesn’t actually have a database, but it’s an example after all).

Redis, however, is one of the things that don’t have database names. So, one thing goes to database 0, another to database 1, and it’s easy to mess this up.

I’ve been pondering the issue for some time, thinking about writing some sort of daemon that would store the associations between names, until it occured me that this is the kind of thing that Redis can do. And since I don’t automate setups, I can just do it by hand without writing external software, just storing all this in database 0.

So what I did when I had to install Sentry was fire up redis-cli, throw KEYS * to see which numbers are in use already (if I were to automate it, it could be more optimal to store the count in a separate variable), and then simply SET sentry 2 and SET 2 sentry.

This probably didn’t save your life, but so be it, it did save mine.