Home > Article > Backend Development > How to query redis in php
redis query data:
To query the data in redis, you need to first connect to redis
1 and 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可能有好几个服务,要指定端口连接。
Related recommendations: "php Basic Tutorial"
2. Redis has five data types: string, list, hash, set, zset. Different data types can be viewed in different ways. different.
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 element from the bottom 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 pass keys * View all keys in Redis.
The above is the detailed content of How to query redis in php. For more information, please follow other related articles on the PHP Chinese website!