REDIS-CLI Command Summary

Source: Internet
Author: User
Tags redis server

Redis provides a rich command to manipulate databases and various data types, which can be used on Linux endpoints. In programming, such as using Redis's Java language Pack, these commands have a corresponding method. The following is a summary of the commands provided by Redis.

Official website Command list: http://redis.io/commands (English)

1. Commands related to connection operation
    • Quit: Close connection (connection)
    • Auth: simple Password Authentication
2. Commands for value operations
  • Exists (key): Verify that a key exists
  • Del (key): Delete a key
  • Type (key): Return value types
  • Keys (pattern): Returns all keys that satisfy the given pattern
  • Randomkey: Randomly returns a key in key space
  • Rename (Oldname, newname): Rename the key from Oldname to newname, or delete the newname-represented key if newname exists
  • Dbsize: Returns the number of keys in the current database
  • Expire: Set the active time of a key (s)
  • TTL: Get the active time of a key
  • Select (Index): Query by index
  • Move (Key, Dbindex): Transfers the key from the current database to the database with the Dbindex index
  • FLUSHDB: Delete all keys in the currently selected database
  • Flushall: Delete all keys in all databases
3. Commands for string manipulation
  • Set (key, value): Assigns a value to a string named key in the database
  • Get (Key): Returns the value of a string named key in the database
  • Getset (key, value): Assigns the last value to a string named key
  • Mget (Key1, Key2,..., key N): Returns multiple strings in the library (their names are key1,key2 ... ) of value
  • SETNX (key, value): If a string with the name key does not exist, add a string to the library with the name key, value
  • Setex (Key, Time, value): Adds a string to the library (with the name key, which is value) and sets the expiration time
  • Mset (Key1, value1, Key2, value2,... key N, value N): Assigning multiple strings at the same time, string assignment value I with Name Key I
  • Msetnx (Key1, value1, Key2, value2,... key N, value N): If all strings with the name key I do not exist, a string is added to the library, the name key I is assigned value I
  • INCR (Key): 1 operation with a string named key
  • Incrby (Key, Integer): String with Name Key added integer
  • DECR (key): string minus 1 operation with name key
  • Decrby (Key, Integer): string with the name key reduced by integer
  • Append (key, value): String value with the name key appended value
  • SUBSTR (key, start, end): Returns a substring of the value of string with the name key
4. Commands for list operations
  • Rpush (key, value): Adds an element of value to the list at the end of the name key
  • Lpush (key, value): Adds an element of value to the list header with the name key
  • Llen (Key): Returns the length of the list named key
  • Lrange (key, start, end): Returns the element between start and end in list named key (subscript starting from 0, same as below)
  • LTrim (key, start, end): Intercepts the list named key, preserving the element between start and end
  • Lindex (key, index): Returns the element of the index position in the list named key
  • LSet (key, index, value): Assigns the element of the index position in the list named key to value
  • Lrem (Key, Count, value): Removes the count of the elements in the list with the name key as value. Count is 0, removing all elements that have values of value, Count>0 removes the element with count values from start to end, Count<0 removes |count| values as value from the tail. Lpop (Key): Returns and removes the first element in the list named key Rpop (key): Returns and removes the tail element in list named key Blpop (Key1, Key2,... key N, timeout): The block version of the Lpop command. That is, when timeout is 0 o'clock, if a list with the name key I does not exist or the list is empty, the command ends. If timeout>0, if this is the case, wait for timeout seconds, and if the problem is not resolved, perform a pop operation on the list starting with keyi+1.
  • Brpop (Key1, Key2,... key N, timeout): The block version of Rpop. Refer to the previous command.
  • 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
5. Commands for SET operations
  • Sadd (Key, member): Adds an element to a set named Key member
  • Srem (Key, member): Removes the element in the set named Key member
  • Spop (key): Randomly returns and deletes an element in a set with the name key
  • Smove (Srckey, Dstkey, member): Moves the member element from a collection named Srckey to a collection named Dstkey
  • SCard (Key): Returns the cardinality of a set named key
  • Sismember (Key, member): Test whether the member is a set element with the name key
  • Sinter (Key1, Key2,... key N): Intersection
  • Sinterstore (Dstkey, Key1, Key2,... key N): Sets the intersection and saves the intersection to Dstkey
  • Sunion (Key1, Key2,... key N): Seek and set
  • Sunionstore (Dstkey, Key1, Key2,... key N): Set and save the set to Dstkey
  • Sdiff (Key1, Key2,... key N): Differential set
  • Sdiffstore (Dstkey, Key1, Key2,... key N): Differential set and save the difference set to Dstkey collection
  • Smembers (Key): Returns all elements of a set with the name key
  • Srandmember (key): Randomly returns an element of a set with the name key
6. Commands for Zset (sorted set) operation
  • Zadd (key, Score, member): Adds an element member,score for sorting to a zset named key. If the element already exists, the order of the element is updated according to score.
  • Zrem (Key, member): Removes the element in Zset with the name Key member
  • Zincrby (key, Increment, member): If the element member already exists in the Zset with the name key, the score of the element is incremented increment; otherwise, the element is added to the collection and its score value is increment
  • Zrank (Key, member): Returns the rank (that is, index, starting from 0) of the member element in the Zset with the name key (the element has been sorted score from small to large), and returns "nil" if there are no member elements
  • Zrevrank (Key, member): Returns the rank (that is, index, starting from 0) of the member element in the Zset with the name key (the element has been sorted by score from large to small), and returns "nil" if there is no member element
  • Zrange (key, start, end): Returns all elements of index from start to end in Zset with the name key (the element has been sorted by score from small to large)
  • Zrevrange (key, start, end): Returns all elements of index from start to end in Zset with the name key (the element has been sorted by score from large to small)
  • Zrangebyscore (Key, Min, max): Returns zset score >= min in the name key and all elements score <= Max Zcard (key): Returns the cardinality of Zset with the name Key Zscore (key , Element): Returns the score Zremrangebyrank (key, Min, max) of elements in Zset with the name key: Delete the Zset in the name key, rank >= min, and rank <= All elements of Max Zremrangebyscore (key, Min, max): Remove all elements of score >= min and score <= Max in Zset named key
  • Zunionstore/zinterstore (Dstkeyn, Key1,..., KeyN, WEIGHTS W1,... WN, AGGREGATE sum| min| MAX): Sets and intersections of N Zset, and saves the last collection in Dstkeyn. For the score of each element in a collection, multiply the weight parameter for the aggregate operation before doing it. If weight is not provided, the default is 1. The default aggregate is sum, that is, the score of the elements in the result set is the value of the sum operation for all the corresponding elements of the collection, while Min and Max means that the score of the elements in the result set are the minimum and maximum values in the corresponding elements of all the collections.
7, the command of the hash operation
  • Hset (Key, field, value): Adds an element to a hash named key Field<->value
  • Hget (Key, field): Returns the value of field corresponding to the hash named key
  • Hmget (Key, field1, ..., field N): Returns the value corresponding to field I in the hash named key
  • Hmset (Key, field1, value1,..., field N, Value N): Adds an element to a hash named key field I<->value I
  • Hincrby (Key, field, integer): Adds an integer to the value of field in the hash named key
  • Hexists (Key, field): A field with the key field in the hash named key
  • Hdel (Key, field): Delete The field with the key field in the hash named key
  • Hlen (Key): Returns the number of elements in a hash with the name key
  • Hkeys (Key): Returns all keys in a hash with the name key
  • Hvals (Key): Returns the value corresponding to all keys in a hash with the name key
  • Hgetall (Key): Returns all keys (field) and their corresponding value in a hash with the name key
8. Persistence
    • Save: Synchronize data to disk
    • Bgsave: Asynchronously saving data to disk
    • Lastsave: Returns the UNIX timestamp when the data was last successfully saved to disk
    • Shundown: Save data synchronously to disk, and then close the service
9. Remote Service Control
    • Info: Provide information and statistics about the server
    • Monitor: Live dump of received requests
    • slaveof: Changing Replication policy settings
    • Config: Configure the Redis server at run time

REDIS-CLI Command Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.