Database / REDIS
What is the purpose of the SELECT command in Redis?
Redis supports multiple numbered logical databases within a single server instance (16 by default, indexed 0-15), and SELECT switches the current connection's active database to a given index, scoping subsequent commands to just that database's keyspace.
SELECT 1 SET debug:flag "on" # stored in database 1, not database 0 SELECT 0 GET debug:flag # returns nil; that key lives in database 1
It's a lightweight way to logically separate data within one Redis instance — for example, keeping a test dataset in database 1 while production data stays in database 0 — without running multiple Redis processes. It's worth knowing the real limitations, though: numbered databases share the same memory pool and the same persistence configuration, offer no per-database access control on their own, and are explicitly unsupported in Redis Cluster mode, which only exposes database 0. For genuine multi-tenant isolation with independent resource limits or access control, separate Redis instances or key-prefixing conventions are generally the better-supported approach.
More Related questions...
