node-redis icon indicating copy to clipboard operation
node-redis copied to clipboard

Permanently select database?

Open jockster opened this issue 13 years ago • 7 comments

Can I permanently select a database for development usage, so that all following queries are run against that database - without having to be wrapped inside a select call like below?

client.select(3, function() { 
  client.stuff...
});

I had a look at the docs, but maybe I have just missed it.

jockster avatar Sep 24 '13 13:09 jockster

I think, only one "select" required, when you initialize the connection, for example client.on('ready',

vpArth avatar Sep 25 '13 11:09 vpArth

@jockster The usage of multiple databases in redis is discouraged by the devs, see https://groups.google.com/forum/#!topic/redis-db/u1IgtiWN0Ww

skenqbx avatar Sep 26 '13 10:09 skenqbx

@skenqbx Thank you for letting me know.

Is there any good other option to be able to keep multiple environments going on the same server when developing/testing? Can we prefix all keys used by node-redis?

jockster avatar Sep 26 '13 18:09 jockster

Hi @jockster generally running multiple Redis instances is considered best practice instead of using dbs. This gives effectively the same functionality while allowing you more flexibility. (e.g. moving one of the instances to a separate server)

There isn't currently a wrapper to auto-prefix keys in node_redis.

brycebaril avatar Sep 26 '13 18:09 brycebaril

Well, for a team of developers - that means a lot of instances. Isn't there an simpler solution?

jockster avatar Sep 30 '13 18:09 jockster

@jockster Prefixing made easy with https://github.com/linus/refix

LoicMahieu avatar Jan 06 '15 09:01 LoicMahieu

Prefixing is on the ToDo-List and will be in one of the upcoming versions.

BridgeAR avatar Oct 15 '15 16:10 BridgeAR