Redis data type operation (i)--string

Source: Internet
Author: User

1. Set

Format: Set ' key ' ' value '

Adds a string-type key-value pair.


2. Get

Format: Get ' key '

Gets the string type value value corresponding to key, and nil is returned if it is not found.


3. Mset

Format: Mset ' key1 ' value1 ' key2 ' value2 ' ...

Adds multiple string-type key-value pairs.


4. Mget

Format: Mget ' key1 ' key2 ' ...

Gets the string type value value corresponding to multiple keys and returns nil if not found.


5. Getset

Format: Getset ' key ' new value '

Get the old value corresponding to the key and set the new value.


6. SETNX (set not exist)

Format: Setnx ' key ' value '

Adds a string-type key-value pair. If the key already exists, neither add nor modify the original value, and return 0, or add if it does not exist, and return 1.


7. Msetnx

Format: Msetnx ' key1 ' value1 ' key2 ' value2 ' ...

Adds multiple string-type key-value pairs. If there is a key already present, do not add or modify the original value, and return 0 if none exists then add, and return 1.


8. Setex (set expire)

Format: Setex ' key ' {num} ' value '

Adds a string-type key-value pair that expires after num seconds.


9. SetRange

Format: SetRange ' key ' {num} ' new-value '

Replaces the value of the original string from the old-value {num} (subscript starting at 0). If value does not have the original string length, the remaining content after the original string is preserved.


Ten. GetRange

Format: GetRange ' key ' {NUM1} {num2}

Gets the {num1} to {num2} string of value.


One. Del

Format: Del ' key1 ' Key2 ' ...

Delete the Key-value key-value pair.


incr.

Format: incr ' key '

The value of key is increased by 1 and is automatically initialized to 0 if it does not exist.


Incrby.

Format: Incrby ' key ' ±{num}

The value of key is incremented by NUM, the key does not exist automatically initialized to 0, and if NUM is negative, it is reduced.


Decr.

Format: DECR ' key '

The value of key is reduced by 1 and is automatically initialized to 0 if it does not exist.


Decrby ' key ' ±num

Format: Decrby ' key ' ±{num}

The value of key is reduced by NUM, the key does not exist automatically initialized to 0, and if NUM is negative, it is incremented.


Append.

Format: Append ' key ' value '

Append value to key.


Strlen.

Format: strlen ' key '

Gets the length of the value of key.




This article is from the "Bronze Gong" blog, please be sure to keep this source http://jaeger.blog.51cto.com/11064196/1772234

Redis data type operation (i)--string

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.