Global command (five basic structures string hsah list set zset)
keys * List all keys, * can replace
dbsize with a specific match (recommended) The size of the library, that is, the total key
exists key Whether there is a key
del key Delete key
expire key seconds seconds after key expires
ttl key remaining expiration time
type key key type
object encoding key internal encoding of key
string
set key value Set the value of the
key setnx key value Set the value of the key, the key cannot exist
setxx key value Set the value of the key, the key must exist
get key Get the value of the key
mset key1 value1 key2 value2 ...... Batch set the value of the key
mget key1 key2 key3 ...... Get the value of the key in batches
incr key key value increments automatically, if there is no corresponding key, the default value is set to 0
append key value append key value
strlen key value length
getset key value set mental return to old value
setrange key offset value set key value offset
getrange key start end Get the value range of the key
Internal code
int 8-byte long integer
embstr String less than or equal to 39 bytes
raw String greater than 39 bytes
Hash
hset key field value Set the value of the hash
hget kek field Get the hash
hdel key field delete the field value of the hash hlen
key get the length of the hash key
hmset key field1 value1 field2 value2 batch set the hash value
hmget key field1 field2 batch get the hash value
Whether there is a corresponding field value in the hexists key field hash
hkeys * Similar to keys * but this is the hvals key corresponding to the hash
Get all the values
of the key hgetall key Get all the filed-value
hincrby key field The filed in the hash is incremented
hincrbyfloat key field The filed in the hash is self-incrementing
hstrlen key field The length of the filed in the hash is
internally encoded
ziplist The compressed list
hashtable
list
rpush lpush linsert rpush
key value1 value2 Left insert data
lpush key value1 value2 Right insert data
/After inserting data
lrange lindex llen
lrange key start end Take out the data in the range
lindex key index Get the data at the specified position
llen key Get the length of the list
lpop rpop lrem ltrim
lpop key Delete data from the left
rpop key Delete data from the right
lrem key count value Find a value equal to value and delete it
ltrim key start end Only keep the data within the range Data
lset
lset key index newValue Modify the value of the specified index subscript
blpop brpop
blpop key1 key2 ...... timeout Block pop-up
brpop key1 key2 ...... timeout
Internal code
ziplist
linkedlist
set sadd
key value1 value2 Add value
srem key value1 value2 Delete value
scar key Calculate the number of elements
sismember key value Whether to set
Yuanshu srandmember key [count] Randomly return the specified number of
Yuanshu spop key Pop up an element at random
smembers key Get all elements
sinter key1 key2 .... .. Intersection
sunion key1 key2 ...... Union
sdiff key1 key2 ...... Difference
sinterstore key key1 key2 ...... Intersection and store
sunionstore key1 key2 ...... Union union Store
sdiffstore key1 key2 ...... difference set and store
internally encoded
intset
hashtable
ordered set
zadd key score1 member1 score2 member2 ...... Add set
zcard key Delete set
zscore key member Calculate member score
zrank key member Calculate member rank
zrevrank key member Calculate member reverse rank
zrem key member1 member2 ...... Delete set element
zincrby key increment member self-increment of the set element
zrange key start end take out the set element
zrevrange key start end reverse take out the set element
zrangebyscore key min max take out the set element according to the score
zrevrangebyscore key min max take out the set element according to the reversal score
zcount key min max return the specified The set of scores
zremrangebyrank key start end deletes the specified set element according to the rank
zremrangebyscore key min max delete the specified set element according to the score
internal code
ziplist
skiplist
key management
rename key newkey rename the key value
randomkey randomly select a key value
expire key seconds seconds after the key expires
persist key persistent key
setex key value seconds set the key value, and set the expiration time
move key db move the key to another database
dump key persist the key
restore key restore the key
flushdb clear the current database
flushall clear all databases
redis basic api
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325292041&siteId=291194637
Ranking