Redis Learning Summary of three--redis client commands

Source: Internet
Author: User
Tags redis server

    • Windows command line launches Redis client

1. Use the default IP address and port to connect to the Redis database (IP address: 127.0.0.1, port number 6379)

Redis-cli

2. Connect to the Redis database using the specified IP address and port

Redis-cli-h 192.168.2.144-p 6379
    • Querying all key values
Keys *
    • Read and write value of string type
1  Set name ' LJX ' //write String type
2 get name//read String type
    • Read/write value of list type
Write list type
1 rpush friends ' Lyt '
2 rpush Friends ' zqj '
Read List type
3 lrange Friends 0-1
    • Read-write hash type value
Write Hash type
1hset address province ' Sichuan '2hset address City ' Chengdu '3Hset Address Detail ' Tianfuxingu '
//Read hash type 4 Hgetall Address
    • Redis instruction Set
1 quit: Close connection (connection)2 Auth: simple password Authentication3  4 Persistence of5  6 Save : Synchronize data to disk7 Bgsave: Asynchronously saving data to disk8 lastsave: Returns the UNIX timestamp when the data was last successfully saved to disk9 Shundown: Save data synchronously to disk, and then close the serviceTen   One Remote Service Control A   - Info: Provide information and statistics about the server - Monitor: Live dump of received requests the 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 A type (key): Return value Types at 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 in Select (index): Query by index - Move (Key, Dbindex): Moves the key in the current database to the Dbindex database to FLUSHDB: Delete all keys in the currently selected database + Flushall: Delete all keys in all databases -   the commands for string manipulation *   $ set (key, value): Assigns a value to a string named key in the databasePanax Notoginseng 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 the mget (key1, Key2,..., key N): Returns the value of multiple strings in the library + setnx (key, Value): Add string, Name key, value A Setex (key, Time, value): Adds a string to the library, sets the expiration Times the 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 the substr (key, start, end): Returns a substring of the value of string with the name key -  Wuyi commands for the list operation the   - Rpush (key, value): Adds an element of value to the list at the end of the name Key Wu 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 About 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 A 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 the 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 the   the commands for set operations the   the Sadd (Key, member): Adds an element to a set named Key member - Srem (Key, member): Removes the element in the set named Key member in Spop (key): Randomly returns and deletes an element in a set named key the Smove (Srckey, Dstkey, member): Move to the collection element the SCard (Key): Returns the cardinality of a set named key About Sismember (Key, member): Member is a set element with the name key the sinter (key1, Key2,... key N): Intersection the Sinterstore (Dstkey, (keys)): Seek the intersection and save the intersection to the collection of Dstkey the sunion (Key1, (keys)): Seek and set + Sunionstore (Dstkey, (keys)): Sets and saves the assembly to the Dstkey collection - Sdiff (Key1, (keys)): Differential set the Sdiffstore (Dstkey, (keys)): Differential set and save the difference set to the collection of DstkeyBayi smembers (Key): Returns all elements of a set with the name key the Srandmember (key): Randomly returns an element of a set named key the   - commands for hash operations -   the Hset (Key, field, value): Adds an element to a hash named key field the Hget (Key, field): Returns the value of field corresponding to the hash named key the hmget (Key, fields): Returns the value of field I in the hash named key the hmset (Key, fields): Adds an element to a hash named key field - Hincrby (Key, field, integer): Adds an integer to the value of field in the hash named key the hexists (Key, field): A field with the key field in the hash named key the Hdel (Key, field): Delete The field with the key field in the hash named key the Hlen (Key): Returns the number of elements in a hash with the name Key94 Hkeys (Key): Returns all keys in a hash with the name Key the hvals (Key): Returns the value corresponding to all keys in a hash with the name Key theHgetall (Key): Returns all keys (field) and their corresponding value in a hash with the name key

Redis Learning Summary of three--redis client commands

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.