Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to query data by redis

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to query data in redis, which has certain reference value and can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

Redis check data:

To query data in redis, you need to connect to redis first.

1. Connect the service

[root@redis1-20 ~] # telnet 127.0.0.1 6380Trying 127.0.0.1...Connected to 127.0.0.1.Escape character is'^]'. # you can also log in with telnet, but you cannot view key's value [root@redis1-20 src] #. / redis-cli-p 6380#redis may have several services. You need to specify a port connection.

2. Redis has five data types: string,list,hash,set,zset. Different data types can be viewed in different ways.

3. View commands

String:get key: gets 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. For example, the position of STATION1,D below is 0, the position of STATION1,D C is 0, the position of start end can also be negative, the position of the first element is-1, the position of the second to last element is-2, and so on.

Hash: hget hash-name key

Set:smembers key

Zset: zrange zset-name 0-1

4. You can view the existing key in Redis through keys *

Thank you for reading this article carefully. I hope it is helpful for everyone to share redis how to query the data content. At the same time, I also hope you can support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report