redis how to switch db
Almost turned 200 on one server redis instance, watching collapsed. You want to do nothing more than different types of data belonging to different applications and separated from each other.
So, redis there any way to make a different application data stored apart from each other at the same time on the same instance of it? Equivalent MySQL database , different application data stored in different databases.
Under redis, the database is an integer index identity, rather than a database name. By default, a client database connected to 0. redis following configuration parameters to control file database Total:
可以通过下面的命令来切换到不同的数据库下
随后,所有的命令将使用数据库3,知道你明确的切换到另一个数据库下。
每个数据库都有属于自己的空间,不必担心之间的key冲突。
不同的数据库下,相同的key取到各自的值。
flushdb命令清除数据,只会清除当前的数据库下的数据,不会影响到其他数据库。
flushall命令会清除这个实例的数据。在执行这个命令前要格外小心。
数据库的数量是可以配置的,默认情况下是16个。修改redis.conf下的databases指令:
redis没有提供任何方法来关联标识不同的数据库。因此,需要你来跟踪什么数据存储到哪个数据库下。
因此上面的快开启200个实例的场景,可以使用不同的数据库来存储,而不必开启如此那么多的实例。
Almost turned 200 on one server redis instance, watching collapsed. You want to do nothing more than different types of data belonging to different applications and separated from each other.
So, redis there any way to make a different application data stored apart from each other at the same time on the same instance of it? Equivalent MySQL database , different application data stored in different databases.
Under redis, the database is an integer index identity, rather than a database name. By default, a client database connected to 0. redis following configuration parameters to control file database Total:
可以通过下面的命令来切换到不同的数据库下
随后,所有的命令将使用数据库3,知道你明确的切换到另一个数据库下。
每个数据库都有属于自己的空间,不必担心之间的key冲突。
不同的数据库下,相同的key取到各自的值。
flushdb命令清除数据,只会清除当前的数据库下的数据,不会影响到其他数据库。
flushall命令会清除这个实例的数据。在执行这个命令前要格外小心。
数据库的数量是可以配置的,默认情况下是16个。修改redis.conf下的databases指令:
redis没有提供任何方法来关联标识不同的数据库。因此,需要你来跟踪什么数据存储到哪个数据库下。
因此上面的快开启200个实例的场景,可以使用不同的数据库来存储,而不必开启如此那么多的实例。