Key command
keys pattern
Get all keys to find all keys that match a given pattern pattern
del key
Delete one or more keys, the nonexistent key is ignored, the return value: the number of deleted keys
exists key
Check if key exists
Expire key second
Set expiration time for key
ttl key
Returns the remaining valid time for a given key, in seconds
persist key
Clears the expiration time of the key. Key persistence.
String:key-value (do Cache)
All data in Redis is a string. The command is case-insensitive, and key is casing-sensitive. Redis is single-threaded. Redis is not suitable for storing large-content data.
get key
Returns the string value associated with key, or returns an error if the value stored by key is not a string type.
set key value
Associating a string value to a key
incr key
Increase the numeric value stored in key by one. Failure to convert to a number is an error.
decr key
Subtract one of the numeric values stored in the key. Key does not exist, the value of the 0,key type incorrectly returns an error.
Hash:key-fields-values (do Cache)
Equivalent to a key for a map,map and key-value, use hash to classify key.
hset key field value
Set the value of the Field field in hash table key to value
hget key field
Returns the value of the given field field in the hash table key
hel key field
Deletes one or more specified domains in the hash table key, and the nonexistent fields are ignored.
hgetall key
Returns the hash table key, all fields and values
hexists key field
View Hash table key, whether a given domain field exists
hkeys key
Returns all the fields in the hash table key
hvals key
Returns the value of all fields in the hash table key
List: Sequential and repeatable
lpush key value
Inserts one or more value values into the table header of the list key
lpop key
Remove and return the header element of the list key
rpush key value
Inserts one or more value values into the footer of the list key
rpop key
Remove and return the tail element of the list key
lrange list 0 -1
Returns the element in the specified interval in the list key, with the interval specified by the offset start and stop
Set: elements are not sequential and cannot be duplicated
sadd key member
Adding one or more member elements to the collection key, member elements that already exist in the collection will be ignored
smembers set1
Returns all members in the collection key
srem key member
Removes one or more member elements from the collection key, and the nonexistent member element is ignored
SortedSet (Zset): sequential, cannot repeat
zadd key member
Adds one or more member elements and their score values to the ordered set key
zrem key member
Remove one or more members from an ordered set key, the nonexistent member will be ignored
zrange key 0 -1
Returns the member within the specified range (small to large) in the ordered set key
zrevrange key 0 -1
Returns the rank of the member member in the ordered set key. Where ordered set members are sorted by score value descending (from large to small)
zrange key 0 -1 withscores
Returns the member within the specified interval in the ordinal set key, including the value of the
Redis Common Commands