Databases

In Redis, databases are identified by integer indices, not by unique names as in some other database systems. By default, Redis configures 16 separate databases (numbered from 0 to 15), and you can select a database using the SELECT command followed by the database index.

By default its db 0


Legacy Feature still available for backward compatibility

To switch to another database

SELECT <db number>

SELECT 1

Data Isolation: While Redis supports multiple databases, the separation is relatively thin. All databases share the same Redis instance resources (memory, CPU, etc.), and commands that operate on the server or affect the global state (like FLUSHALL or CONFIG) will affect all databases.

Use in Production: Multiple databases within a single Redis instance are less common in production environments. Instead, it's often recommended to use separate Redis instances for data that needs to be logically separated, as this approach provides stronger data isolation and can prevent one application's data from impacting another.

Persistence and Backup: Be aware that RDB and AOF persistence files contain data from all databases in the Redis instance. If you're using persistence, backing up or restoring these files will back up or restore data for all databases, not just one.

Last updated