redis data query:
To query the data in redis, you need to connect to redis first
1. Connect to the service
[root@redis1-20 ~]# telnet 127.0.0.1 6380 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. #用telnet也能登录,但是无法查看key的value
[root@redis1-20 src]# ./redis-cli -p 6380 #redis可能有好几个服务,要指定端口连接。
2. Redis has five data types: string, list, hash, set, zset. Different data types have different ways of viewing values.
3. View command
string: get key: Get the value of the specified key
list: lrange key start end: Get the value from start to end in the linked list, start starts from 0, like STATION1 below, the position of D is 0, the position of C is 1, start and end can also be negative numbers, the position of the first to last element is -1, and the position of the second to last element is -2, so analogy.
hash: hget hash-name key
set:smembers key
zset: zrange zset-name 0 -1
4. You can view the existing keys in Redis through keys *
Redis usage tutorialcolumn!
The above is the detailed content of How to query data in redis. For more information, please follow other related articles on the PHP Chinese website!