redis Access database

edis number database is configurable, default is 16, see redis.windows.conf / redis.conf of databases 16.
A database corresponding to the index value of 0 - (databases -1), i.e. the database 16, the index value of 0-15. The default storage database to zero.

It is not different indices of access

1, command-line switch
redis-cli -a 123456
landing Redis, bank 0 is selected by default, if the need to switch to another database using the select index value, such as a handoff to select an index value of a database.
D: \ Software \ Redis> -a Redis CLI-123456
127.0.0.1:6379> SELECT. 1
the OK
127.0.0.1:6379 [. 1]>

After switching would have been in operation is the new database until the next shift becomes effective.


2, springboot designated redis database

#redis
spring.redis.host = localhost
spring.redis.password = 123456
spring.redis.port = 6380 // Redis SSL port
spring.redis.database = 2 // database index used
spring.redis.ssl = true // whether ssl, defaults to false
spring.redis.pool.maxActive = 100
spring.redis.pool.maxWait = 1000000
spring.redis.pool.maxIdle = 10
spring.redis.pool.minIdle = 0
spring.redis.timeout = 0
= to true spring.redis.testOnBorrow
spring.redis.testOnReturn to true =
spring.redis.testWhileIdle to true =

RedisProperties.java in the source code, the database is the initial value is 0 (private int database = 0;), and therefore is not specified redis database in the default configuration to a No. 0 springboot database, configure this value is used to configure their own database.

3, related commands

keys “spiring*“”

hash

hget   "spring:session:sessions:6761a285-3533-481d-becd-84ae253e2097" "sessionAttr:app_currentUser"

string

get "sessionid:dbc145a2-1b9b-4c02-b461-9132c4bdb156" 

Guess you like

Origin www.cnblogs.com/daixs/p/11278409.html