How Redis commands are organized and used

Source: Internet
Author: User
Tags redis server
This article mainly introduces the Redis command to organize and explain how to use the relevant information, the need for friends can refer to, hope to help everyone.

Commands related to connection operations

    • Quit: Close connection (connection)

    • Auth: simple Password Authentication

Persistence of

    • 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

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

Commands for the value operation

    • 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 one of the key spaces

    • Keyrename (Oldname, newname): Rename key

    • 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): Moves 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 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 the value of multiple strings in the library

    • SETNX (key, Value): Add string, name key, value

    • Setex (Key, Time, value): Adds a string to the library, sets the expiration times

    • Mset (key n, value N): Sets the value of multiple strings in bulk

    • Msetnx (key n, value N): If all strings with the name key I do not exist

    • 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

Commands for the list operation

    • 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

    • LTrim (key, start, end): Intercepts the list named key

    • Lindex (key, index): Returns the element of the index position in the list named key

    • LSet (key, index, value): Assigns a value to the element of the index position in the list named key

    • Lrem (Key, Count, value): Deletes the value in the list of Count key elements

    • Lpop (Key): Returns and removes the first element in a list named key

    • Rpop (Key): Returns and Deletes 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

    1. Sadd (Key, member): Adds an element to a set named Key member

    2. Srem (Key, member): Removes the element in the set named Key member

    3. Spop (key): Randomly returns and deletes an element in a set with the name key

    4. Smove (Srckey, Dstkey, member): Move to the collection element

    5. SCard (Key): Returns the cardinality of a set named key

    6. Sismember (Key, member): Member is a set element with the name key

    7. Sinter (Key1, Key2,... key N): Intersection

    8. Sinterstore (Dstkey, (keys)): Seek the intersection and save the intersection to the collection of Dstkey

    9. Sunion (Key1, (keys)): Seek and set

    10. Sunionstore (Dstkey, (keys)): Sets and saves the assembly to the Dstkey collection

    11. Sdiff (Key1, (keys)): Differential set

    12. Sdiffstore (Dstkey, (keys)): Differential set and save the difference set to the collection of Dstkey

    13. Smembers (Key): Returns all elements of a set with the name key

    14. Srandmember (key): Randomly returns an element of a set with the name key

Commands for hash operations

    1. Hset (Key, field, value): Adds an element to a hash named key field

    2. Hget (Key, Field): Returns the value

    3. Hmget (Key, fields) in the hash with the name key: Returns the value of field I in the hash named key

    4. Hmset (Key, fields): Adds an element to a hash named key field

    5. Hincrby (Key, field, integer): Adds an integer

    6. to the value of field in the hash named key.
    7. Hexists (Key, field): A field with key field

    8. if a hash with the name key is present
    9. Hdel (Key, field): Delete The field with the key field in the hash named key

    10. Hlen (Key): Returns the number of elements in a hash named key

    11. Hkeys (key): Returns all keys in a hash with the name key

    12. Hvals (Key): Returns the value

    13. for all keys in a hash with the name key
    14. Hgetall (key): Returns all keys (field) and their corresponding value

    in a hash with the name key

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.