The latest summary of Redis-cli commands

Commands related to connection operations

  • Default direct connection remote connection -h 192.168.1.20 -p 6379
  • ping: test whether the connection is alive or not, it will return pong if it is normal
  • echo: print
  • select: switch to the specified database, the database index number is specified indexwith a numerical value 0as the starting index value
  • quit: close the connection (connection)
  • auth: simple password authentication


Server related commands

  • time: returns the current server time
  • client list: returns all client information and statistics connected to the server see http://redisdoc.com/server/client_list.html
  • client kill ip:port: close ip:portthe
  • save: save data to disk synchronously
  • bgsave: save data to disk asynchronously
  • lastsave: Returns the Unix timestamp of the last successful save of data to disk
  • shundown: Sync data to disk, then shut down the service
  • info: Provides server information and statistics
  • config resetstat: reset some statistics in info command
  • config get: get configuration file information
  • config set: Dynamically adjust the configuration of the Redis server without restarting. The configuration parameters that can be modified can beCONFIG GET *
  • config rewrite: The redis.conffile rewritten
  • monitor: Dump received requests in real time
  • slaveof: change replication policy settings

<!--more-->

Publish and subscribe related commands

  • psubscribe: Subscribe to one or more channels matching a given pattern e.g. psubscribe news.* tweet.*
  • publish: send the messagemessage to the specified channelchannel 例如publish msg "good morning"
  • pubsub channels: List currently active channels such as PUBSUB CHANNELS news.i*
  • pubsub numsub: returns the number of subscribers for a given channel e.g. PUBSUB NUMSUB news.it news.internet news.sport news.music
  • pubsub numpat: returns the sum of the number of all schemas subscribed by the client
  • p unsubscribe: Instructs the client to unsubscribe from all given modes.
  • subscribe: Subscribe to a given channel or channels for information. For example subscribe msg chat_room
  • unsubscribe: Instructs the client to unsubscribe from the given channel.


Commands for KEY operations

  • exists(key): Confirm whether a key exists
  • del(key): delete a key
  • type(key): the type of the return value
  • keys(pattern): returns all keys that satisfy the given pattern
  • randomkey: randomly returns one of the key space
  • keyrename(oldname, newname): rename key
  • dbsize: returns the number of keys in the current database
  • expire: Set the active time (s) of a key
  • ttl: get the active time of a key
  • move(key, dbindex): move the key in the current database to the dbindex database
  • flushdb: delete all keys in the currently selected database
  • flushall: delete all keys in all databases


Commands for String Operations

  • set(key, value): assign the value value to the string named key in the database
  • get(key): Returns the value of the string named key in the database
  • getset(key, value): assign the last value to the string named key
  • mget(key1, key2,..., key N): Returns the value of multiple strings in the library
  • setnx(key, value): add string, name is key, value is value
  • setex(key, time, value): add string to the library, set the expiration time time
  • mset(key N, value N): batch set the value of multiple strings
  • msetnx(key N, value N): if all strings named key i do not exist
  • incr(key): increment the string named key by 1
  • incrby(key, integer): the string named key adds integer
  • decr(key): subtract 1 from the string named key
  • decrby(key, integer): the string named key reduces the integer
  • append(key, value): append value to the value of the string named key
  • substr(key, start, end): Returns the substring of the value of the string named key


Commands for List Operations

  • rpush(key, value): add an element whose value is value to the end of the list named key
  • lpush(key, value): Add an element whose value is value to the list header named key
  • llen(key): returns the length of the list named key
  • lrange(key, start, end): Returns the elements between start and end in the list named key
  • ltrim(key, start, end): intercept the list named key
  • lindex(key, index): Returns the element at the index position in the list named key
  • lset(key, index, value): Assign a value to the element at the index position in the list named key
  • lrem(key, count, value): delete the element whose value is value in the list of count keys
  • lpop(key): Returns and deletes the first element in the list named key
  • rpop(key): Returns and removes the tail element in the list named key
  • blpop(key1, key2,… key N, timeout): The block version of the lpop command.
  • brpop(key1, key2,… key N, timeout): The block version of rpop.
  • rpoplpush(srckey, dstkey): Returns and removes the tail element of the list named srckey and adds the element to the head of the list named dstkey


Commands for Set Operations

  • sadd(key, member): Add the element member to the set named key
  • srem(key, member) : delete the element member in the set named key
  • spop(key) : Randomly returns and deletes an element in the set named key
  • smove(srckey, dstkey, member) : move to set element
  • scard(key) : returns the cardinality of the set named key
  • sismember(key, member) : Whether member is an element of the set named key
  • sinter(key1, key2,…key N) : find the intersection
  • sinterstore(dstkey, (keys)) : find the intersection and save the intersection to a collection of dstkeys
  • sunion(key1, (keys)) : union set
  • sunionstore(dstkey, (keys)) : a collection that takes the union and saves the union to dstkey
  • sdiff(key1, (keys)) : find the difference
  • sdiffstore(dstkey, (keys)) : find the difference and save the difference to the set of dstkey
  • smembers(key) : Returns all elements of the set named key
  • srandmember(key) : Randomly returns an element of the set named key


Commands for Hash Operations

  • hset(key, field, value): add the element field to the hash named key
  • hget(key, field): Returns the value corresponding to the field in the hash named key
  • hmget(key, (fields)): Returns the value corresponding to field i in the hash named key
  • hmset(key, (fields)): add the element field to the hash named key
  • hincrby(key, field, integer): Increase the value of the field in the hash named key by integer
  • hexists(key, field): Whether there is a field with the key field in the hash named key
  • hdel(key, field): delete the field whose key is field in the hash named key
  • hlen(key): returns the number of elements in the hash named key
  • hkeys(key): Returns all keys in the hash named key
  • hvals(key): Returns the value corresponding to all keys in the hash named key
  • hgetall(key): Returns all keys (fields) and their corresponding values ​​in the hash named key

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326375962&siteId=291194637