200 Redis instances are turned on on a single server, and it crashes when you look at it. The only way to do this is to make different types of data belong to different applications and separate from each other.
So, isthere a way for Redis to keep different application data separate from each other and stored on the same instance? is equivalent to the MySQL database , different application data is stored under different databases.
Under Redis, a database is identified by an integer index, not by a database name. By default, one client connects to database 0. The following parameters in the Redis configuration file control the total number of databases:
/etc/redis/redis.conf file, there is a configuration entry databases = 16//default of 16 databases
You can switch to a different database by using the following command
Subsequently, all commands will use database 3, knowing that you explicitly switch to another database.
Each database has its own space, and there is no need to worry about key conflicts.
Under different databases, the same key is taken to the respective value.
The FLUSHDB command clears the data and clears only the data under the current database, without affecting other databases.
The Flushall command clears the data for this instance. Take extra care before executing this command.
The number of databases is configurable and is 16 by default. Modify the Databases directive under redis.conf:
Redis does not provide any way to correlate the identities of different databases. Therefore, you need to keep track of what data is stored under which database.
As a result, the above 200-instance scenario can be stored using a different database instead of having so many instances open.
How to switch DB in Redis