Redis Common Commands

Source: Internet
Author: User
Tags redis server

DEL key [key ...] deletes the given one or more key spaces separately.
EXISTS phone to determine if key exists
EXPIRE Cache_page 30 # Set the expiration time to 30 seconds
TTL cache_page # View remaining live time
Move song 1 moves song to database 1

Lpush T9 "value 1" is stored as a linked list
Lpush T9 "Value 1"
Lrange T9 0 2 The value index is 012
Llen T9 Length
Linsert T9 berore he5 "99" Insert "99" in front of He5
LTRIM T9 1 3 only keep index 123 other deletions

Commands related to connection operations
Quit: Close connection (connection)
Auth: simple Password Authentication 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 turn off 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

Value action command
exists (key): Verify that 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 a
Keyrename (oldname, newname) of the key space: Rename key
Dbsize: Returns the number of keys in the current database
expire: Sets the active time (s) of a key
TTL: Gets the active time of a key
Select index: Query by index
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

Command for string operation
Set (key, value): Assigns a value to the string named key in the database to the values
Get (Key): Returns the value of string named key in the database
Getset ( Key, value): gives a string named key the last value
Mget (key1, Key2,..., key N): Returns the value of multiple strings in the library
Setnx (key, Value): Add string , named key, Value
Setex (key, time, value): Add string to library, set expiration time
Mset (key n, value N) : Batch setting of multiple string values
Msetnx (key n, value N): If all strings with the name Key i do not exist
INCR (key): A string with the name of Key 1 operation
Incrby ( Key, Integer): String with Name Key added integer
DECR (key): string minus 1 operation with name Key
Decrby (key, Integer) : string with name key is reduced by integer
Append (key, value): String value with Name key appended value
substr (key, start, end) : Returns a substring of the value of string named key

Rpush (key, value): Adds an element of value to the list at the end of the name Key
Lpush (key, value): Adds a   element of value to the list header named 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
Lindex (key, index) named key: Returns the element with the index position in the list named key
LSet (key, index, value) : Assigns the element of the index position in the list named key
Lrem (key, Count, value): Removes the element with value in the list of Count keys
Lpop (key) : Returns and removes the first element of 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

Command for set operation
Sadd (key, member): Adds an element to a set named Key member
Srem (key, member)  : Deletes an element in a set named Key member
Spop (key)  : Randomly returns and deletes an element in the set named Key
Smove (Srckey, Dstkey, member)  : Move to the collection element
SCard (key)   : Returns the cardinality of the set named Key
Sismember (key, member)  :member is a set element named Key
Sinter (Key1, Key2,... key N)  : Intersection
Sinterstore (Dstkey, (keys))  : Intersection and save intersection to Dstkey collection
Sunion (Key1, Keys)  : Set
Sunionstore ( Dstkey, (keys))  : Sets and saves the set to Dstkey collection
Sdiff (Key1, (keys))  : Differential set
Sdiffstore (Dstkey, (keys))   : The differential set and save the difference to the collection of Dstkey
Smembers (key)  : Returns all elements of a set named Key
Srandmember (key)  : Randomly returns an element of a set with the name key

Commands for hash operations
Hset (Key, field, value): Adds an element to a hash named key field
Hget (Key, field): Returns the value of field corresponding to the hash named key
Hmget (Key, fields): Returns the value of field I in the hash named key
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
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

Redis Common 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.