Home > Database > Redis > What are the basic data query commands in redis?

What are the basic data query commands in redis?

王林
Release: 2023-05-31 17:19:06
forward
1616 people have browsed it

(1) key query

1. Query all keys

KEY *
Copy after login

2. Query the key containing a certain character

KEY *字符*
Copy after login

For example, query key containing the character chen is available

KEY *chen*
Copy after login

3. Query the type of key

TYPE key
Copy after login

4. Query whether a key exists

EXISTS key
Copy after login

(2) Query commands for 5 data types

1 .string query

1.1 Query the value of string type key

GET string_key
Copy after login

1.2 Query the length of string type key

STRLEN string_key
Copy after login

1.3 Query the value of multiple string type key

MGET string_key1 [string_key2........]
Copy after login

2.Hash query

2.1. Query a certain filed value of a single hash type key

HGET hash_key filed
Copy after login

2.2. Query multiple filed values ​​of a hash type key

HMGET hash_key filed1 [filed2.......]
Copy after login

2.3. Query all filed values ​​of hash type keys and their corresponding values

HGETALL hash_key
Copy after login

2.4. Query all filed values ​​of hash type keys

HKEYS hash_key
Copy after login

2.5. Query all filed values ​​of hash type keys

HVALS hash_key
Copy after login

2.6 Query the length of hash type key

HLEN hash_key
Copy after login

3.Set query

3.1.Query all elements of set type key

SMEMBERS set_key
Copy after login

3.2.Query the number of elements of set type key

SCARD set_key
Copy after login

4.zset query

4.1. Query the elements whose zset type key index is within a certain range

ZRNAGE zset_key start stop [withsocres]
Copy after login

4.2. Query the elements whose zset type key score is within a certain range

ZRNAGEBYSCORE zset_key start stop [withsocres]
Copy after login

5.list query

5.1.Query elements whose list type key index is within a certain range

LRANGE list_key start stop
Copy after login

5.2.Query a certain index value of list type key

LINDEX list_key index
Copy after login

5.3. Query the length of list type key

LLEN list_key
Copy after login

The above is the detailed content of What are the basic data query commands in redis?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
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