Home > Database > Redis > body text

How to query data in redis

Release: 2019-07-04 14:48:13
Original
96569 people have browsed it

How to query data in redis

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
Copy after login
[root@redis1-20 src]# ./redis-cli -p 6380
#redis可能有好几个服务,要指定端口连接。
Copy after login

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 *

##For more Redis related knowledge, please visit the

Redis usage tutorial column!

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template