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

What are the basic data query commands in redis?

王林
王林forward
2023-05-31 17:19:061580browse

(1) key query

1. Query all keys

KEY *

2. Query the key containing a certain character

KEY *字符*

For example, query key containing the character chen is available

KEY *chen*

3. Query the type of key

TYPE key

4. Query whether a key exists

EXISTS key

(2) Query commands for 5 data types

1 .string query

1.1 Query the value of string type key

GET string_key

1.2 Query the length of string type key

STRLEN string_key

1.3 Query the value of multiple string type key

MGET string_key1 [string_key2........]

2.Hash query

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

HGET hash_key filed

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

HMGET hash_key filed1 [filed2.......]

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

HGETALL hash_key

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

HKEYS hash_key

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

HVALS hash_key

2.6 Query the length of hash type key

HLEN hash_key

3.Set query

3.1.Query all elements of set type key

SMEMBERS set_key

3.2.Query the number of elements of set type key

SCARD set_key

4.zset query

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

ZRNAGE zset_key start stop [withsocres]

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

ZRNAGEBYSCORE zset_key start stop [withsocres]

5.list query

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

LRANGE list_key start stop

5.2.Query a certain index value of list type key

LINDEX list_key index

5.3. Query the length of list type key

LLEN list_key

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete