Get the App
SLTechnology News&Howtos  ›  Database  › 

How to query data by redis

Shulou Source: shulou.com Published: 2022-06-01 03:34:28 09月27日 Update

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!

Tags: Data query location article different type service and so on value element content can be passed at the same time command way method friend port ribbon Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno MySQL vpn Shulou Tech Info MariaDB