Redis command Chinese manual

Source: Internet
Author: User

 

Redis command Chinese manual

 

I. Base

Del Delete a key or a series of keys; del key1 key2 key3 key4
Type Returns the Data Type of a key element (none: nonexistent, string: character, list, set, zset, hash)
Keys Returns the matched Key List (Keys Foo *: Search for keys starting with Foo)
Randomkey Obtain an existing key at random
Rename Change the key name. If the name exists, the change fails.
Dbsize Returns the total number of keys of the current database.
Expire Set the expiration time of a key (in seconds), (expire Bruce 1000: the system automatically deletes the key after setting Bruce's key1000 seconds)
TTL How long does it take to query the expiration time of a key? The returned time is second.
Select Select Database
Move Transfers keys from one database to another
Flushdb Clear current database data
Flushall Clear all database data
Set Store a piece of data to the database set keyname datalength data (set Bruce 10 paitoubing: Save a string paitoubing with the key as burce and the string length as 10 to the database)
Get Obtains the value of a key.
GetSet GetSet can be understood as the obtained key value and then set this value for more convenient operations (set Bruce 10 paitoubing. In this case, you need to modify Bruce to 1234567890 and obtain the previous data paitoubing, getSet Bruce 10 1234567890)
Mget Obtain data of multiple keys at a time (mget uid: 1: Name uid: 1: email uid: 1: ciy)
Setnx The difference between setnx and set is that set can create and update the key value. If setnx does not exist, the key and value data will be created.
Setex Setex = set + expire. It seems that I cannot test this version.
Mset Set the value of multiple parameters at a time (mset uid: 1: Name shjuto uid: 1: email shjuto@gmail.com uid: 1: city 8 press ENTER Nanchang) The last value needs to press enter, like set, I don't know why.
Msetnx If the set key does not exist, or is called a new key; set the value of multiple parameters at a time (mset uid: 1: Name shjuto uid: 1: email shjuto@gmail.com uid: 1: city 8 press ENTER Nanchang) The last value needs to press Enter. It is the same as set.
Incr Auto-incrementing. Some classes are MySQL incr. (incr Global: UID)
Incrby Auto-increment + length, (incrby uid 5) original base + 5 = Result
Decr Auto-Subtraction
Decrby Decrby auto-subtraction-lenght


 

Ii. Lists (no index sequence. The head position is 0 ,......)

 

Rpush Append data to the end of the series (rpush listtest 10 \ n 1111111122)
Lpush Append data to the sequence header (lpush listtest 10 \ n 2222222222)
Llen Length of a sequence; (llen listtest)
Lrange Returned sequence elements from a custom range (lrange testlist 0 2; returns the first 0 1 2 elements of the sequence testlist)
Ltrim Trim Data out of a certain range (ltrim testlist 0 2; Retain 0 1 2 elements, and delete the remaining)
Lindex Returns the value of the sequence at a certain position (lindex testlist 0; returns the element with zero position of the sequence testlist)
Lset Update the value of an element at a certain position (lset testlist 0 5 \ n 55555 ;)
Lpop Lpop key return and remove (atomically) the first element of the list at key
Rpop Rpop key return and remove (atomically) the last element of the list at key
Lrem

Delete the sequence element (lrem testlist 0 5 \ n 33333; delete all the elements equal to 33333 in the sequence. Why not remove by key? I don't know why. It may be useful for deleting duplicate data)

 

Iii. Sets (with unordered index sequences)

 

Sadd Add the element to the sets sequence. If the element does not exist, 1 is successfully added; otherwise, 0 is failed; (sadd testlist 3 \ n one)
Srem Delete an element of the sets sequence. If the element is not stored, 0 is failed; otherwise, 1 is successful (Srem testlist 3 \ n one)
Spop Randomly delete an element (spop testlist)
Smove

Move an element of a set sequence to another set sequence (smove testlist Test 3 \ n two; move the element two from the sequence testlist to test, and the two element will not exist in-testlist)

Scard Count the number of elements in a sequence of sets (scard testlist)
Sismember Production to check whether a data is in the sequence (sismember testlist 3 \ n two)
Sinter The intersection of several sets, sinter key1 key2... Keyn (sinter test testlist), Niu B
Sinterstore

Record the calculated intersection to a new sequence sinterstore dstkey key1 key2... Keyn (sinterstore resultlist testlist test; records the intersection of testlisttest to resultlist)

Sunion The Union of several sets of sequences sunion key1 key2... Keyn (sunion test testlist)
Sunionstore

Record the calculated union to a new sequence sunionstore dstkey key1 key2... Keyn (sunionstore resultlist testlist test; records the intersection of testlisttest to resultlist)

Sdiff

Sdiff key1 key2... Keyn: Calculate the Union of several sequences and the traveling set of a specific sequence. See the official example:

Key1 = X, a, B, c

Key2 = C

Key3 = A, D

Sdiff key1, key2, key3 => X, B

Sdiffstore Sdiffstore dstkey key1 key2... Keyn, similar to the previous sinterstore sunionstore.
Smembers Smembers key returns all elements of a sequence.
Srandmember Srandmember key returns random elements of a sequence.
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.