The Redis command collates and explains how to use it

  • 2020-05-14 05:21:07
  • OfStack

Connect the commands associated with the operation

quit: close the connection (connection) auth: simple password authentication

persistence

save: saves data synchronously to disk bgsave: saves data asynchronously to disk lastsave: returns the Unix timestamp from the last time data was successfully saved to disk shundown: synchronizes data to disk, then closes the service

Remote service control

info: provides information and statistics about the server monitor: dump incoming requests in real time slaveof: changes replication policy Settings config: configure the Redis server at run time

Command for value operations

exists(key) : verify the existence of an key del(key) : delete 1 key type(key) : type of return value keys(pattern) : returns all key that satisfy a given pattern randomkey: randomly returns 1 key space keyrename(oldname, newname) : rename key dbsize: returns the number of key in the current database expire: set one key activity time (s) ttl: get 1 key activity time select(index) : query by index move(key, dbindex) : move the key to dbindex databases in the current database flushdb: deletes all key in the currently selected database flushall: delete all key in all databases

Command for String operations

set(key, value) : assign the value value to string with the name key in the database get(key) : returns value of string with the name key in the database getset(key, value) : assign value to string named key once before mget (key1, key2,... , key N) : returns value of multiple string in the library setnx(key, value) : add string, name key, value value setex(key, time, value) : add string to the library and set the expiration time time mset(key N, value N) : batch sets multiple string values msetnx(key N, value N) : if all string with the name key i do not exist incr(key) : the string increment operation named key incrby(key, integer) : add integer to string named key decr(key) : string minus 1 operation named key decrby(key, integer) : string, key reduced integer append(key, value) : the value of string, named key, is appended to value substr(key, start, end) : returns a substring of value of string with the name key

Command for List operation

rpush(key, value) : at the end of list with the name key, add an element with the value value lpush(key, value) : add an element with the value value to the list header named key llen(key) : returns the length of list with the name key lrange(key, start, end) : returns the element between start and end in list with the name key ltrim(key, start, end) : intercept list with the name key lindex(key, index) : returns the element of the index position in list with the name key lset(key, index, value) : assign a value to the index position in list named key lrem(key, count, value) : delete the element with value as the median of list for count key lpop(key) : returns and deletes the first element in list with the name key rpop(key) : returns and deletes the tail element in list with the name key blpop (key1, key2,... key N, timeout) : block version of the lpop command. brpop (key1, key2,... key N, timeout) : block version of rpop. rpoplpush(srckey, dstkey) : returns and removes the tail element of list named srckey, and adds the element to the head of list named dstkey

Command for the Set operation

sadd(key, member) : adds the element member to set with the name key srem(key, member) : delete the element member in set with the name key spop(key) : randomly returns and deletes an element in set named key smove(srckey, dstkey, member) : move to the collection element scard(key) : returns the cardinality of set with the name key sismember(key, member) : is member an element of set named key sinter (key1, key2,... key N) : find the intersection sinterstore(dstkey, (keys)) : find the intersection and save the intersection to the collection of dstkey sunion(key1, keys) : union sunionstore(dstkey, (keys)) : find a union and save the union to the set of dstkey sdiff(key1, (keys)) : difference set sdiffstore(dstkey, (keys)) : find the difference set and save the difference set to the set of dstkey smembers(key) : returns all elements of set with the name key srandmember(key) : randomly returns an element of set with the name key

Command for Hash operation

hset(key, field, value) : add the element field to hash with the name key hget(key, field) : returns value for field in hash with the name key hmget(key, (fields)) : returns the value corresponding to field i in hash with the name key hmset(key, (fields)) : adds the element field to hash named key hincrby(key, field, integer) : add integer to field in hash named key hexists(key, field) : does hash with the name key have a domain with the key field hdel(key, field) : deletes the domain in hash whose name is key and whose key is field hlen(key) : returns the number of elements in hash with the name key hkeys(key) : returns all keys in hash with the name key hvals(key) : returns value for all keys in hash with the name key hgetall(key) : returns all the keys (field) in hash with the name key and their corresponding value

Thank you for reading, I hope to help you, thank you for your support of this site!


Related articles: