1. For the operation of KEY
1)keys *
keys *
View all keys in the database
2)exists
exists key name
Determine whether a key exists (1 means it exists, 0 means it does not exist)
3)move
move key db
Move a key to a database
4)expire
expire key seconds
Set the expiration time of the key in seconds by default
5)ttl
ttl key
Check how many seconds have expired, -1 means never expire, -2 means expired
6)type
type key
Check what type of key is
2. Operations on strings
1)set/get/del/append/strlen
set key value //Set the key value pair
get key //Get the value of the corresponding key
del key //Delete the value of the corresponding key
append key Add content //Add content to the value of the corresponding key
strlen key //View the value of the corresponding key length
2)Incr/decr/incrby/decrby
incr key //corresponding to key value +1
decr key //corresponding to key value -1
incrby key num //corresponding to key value +num
decrby key num //corresponding to key value -num
3) getrange / setrange
getrange key num1 num2 //Get the value of num1 to num2 (num is a string subscript)
setrange key num1 Set the content//Set the value within the specified range
4) setex(set with expire)/setnx(set if not exist)
setex key expiration time value //Set the key with expiration time
setnx key value //Set the value of the key only when the key does not exist
5)mset/mget/msetnx
mset key1 value1 key2 value2… //Set multiple key-value pairs at the same time
mget key1 key2… //Take multiple key-value pairs at the same time
6) getset (get first and then set)
getset key value //Get the old value of the key and assign the new value that is value
3. Operations on Redis lists
1) lpush / rpush / lrange
lpush key v1 v2 v3 //Set the key list value (similar to a stack)
rpush key v1 v2 v3 //Set the key list value (similar to a queue)
lrange key num1 num2 //Get the value of the key corresponding to the specified range
2)lpop/rpop
lpop key //take the value from the head
rpop key //take the value from the tail
3) lindex
lindex key array subscript
Index to get the elements in the list
4) llen
fill key
Number of list elements
5)lrem key
lrem key num value
Delete num elements with value from left to right
6) ltrim
ltrim key start index end index //Intercept the value of the specified range and assign it to the key
7) rpoplpush
rpoplpush source list destination list // remove the last element of the list, add the element to another list and return
8 set lset
lset key index value //Add value to the index of the key value
value
9) linsert
linsert key before/after v1 v2 //Add v2 before/after the position of v1 in the key list
4. Set operation
1) sadd / smembers / sismember
sadd key value1 value2… //Set the set collection
smembers key //View the set collection
sismember key value //Determine whether the member element is a member of the set
2) scard
scard key //Get the number of elements in the collection
3)srem
srem key value //Delete elements in the collection
4)srandmember
srandmember key num //Randomly take out several values in the set collection and replace them
5) spop
spop key // randomly pop out of the stack
6) smove
smove key1 key2 a value in key1 // assign a value in key1 to key2
7)sdiff/sinter/sunion
sdiff key1 key2 //Differential set
sinter key1 key2 //Intersection
sunion key1 key2 //Union
5. Hash operation
1) hset/hget/hmset/hmget/hgetall/hdel
hset key value(key value) //Set a key hash value (key-value pair)
hget key value(key) //Get a key-value pair corresponding to the key. The value value of the corresponding key is
hmset key1 value1(key value) key2 value2(key value) //Batch setting hash
hmget key1 value1(key) value2(key) //Bulk or hash corresponding value
hashtall key //Get all hash key value pairs corresponding to key
hdel key value(key ) //Delete the key-value pair of the hash corresponding to the key
2 select
hlen key //View the number of hash key-value pairs corresponding to the key
3)hexists
hexists key The key of a certain value in the key //Query whether the key of the key-value pair corresponding to the key exists
4) hkeys / whale
hkeys key //Get all the keys of the hash key-value pair corresponding to the key
hvals key //Get all the values of the hash key-value pair corresponding to the key
5)hincrby/hincrbyfloat
hincrby key value(key) num //Set the hash key-value pair key corresponding to the key to value +num (integer)
hincrbyfloat key value(key) num //Set the hash key-value pair key corresponding to the key to value Value+num (floating point number)
6)hsetnx
hsetnx key value(key value) //There is no assignment, the existence is invalid
6, zset operation
1)zadd/zrange/zrevrange
zadd key score1 value1 score2 value2 //Set an ordered set
zrange key num1 num2 //Get the value of the zset corresponding to the key between num1 and num2 (positive order)
zrange key num1 num2 withscores //Get the zset corresponding to the key below Marked as the value between num1 and num2 (a mixed number)
zrevrange key num1 num2 //Get the value of the zset corresponding to the key between num1 and num2 (reverse order)
2)zrangebyscore /zrevrangebyscore
zrangebyscore key start score end score //return the value within the range of zset score corresponding to key (positive order)
zrangebyscore key start score end score withscores//return the value within the range of zset score corresponding to key (with score)
zrangebyscore key (start score (end) score //Return the value within the range of the key corresponding to the zset score (not including the start score and the end score)
zrangebyscore key Start score and end score limit How many
zrevrangebyscore key after the start subscript End score Start score //Return the key corresponding to the zset score range Value (reverse order)
3) zrem
zrem key The value corresponding to a score//delete the value of zset corresponding to the key
4)zcard/zcount
zcard key //Get the number of elements in the set
zcount key Start score End score //Get the number of elements in the score range
zrank key values //Get the subscript position of value in zset
5) zrevrank / zrank
zrevrank key value //obtain subscript value in reverse order zrank key value //obtain subscript value in
positive order