Redis command collection 1 (string type), redis collection

Source: Internet
Author: User

Redis command collection 1 (string type), redis collection

The article is shared by the blog and author "Snail. Repost and crawler please specify the original Redis series link http://www.cnblogs.com/tdws/tag/NoSql/

Redis hasFive Basic Data Types. They areString, hash, list, set, sorted set. Actually, the last four types of string keys are organized in different forms.

You can use it to store any piece you want.OverallData is the overall data. For the title, Tag, content, and comment of an article, although you can serialize its object to Json storage, strings are not recommended. As a whole storage, when you want to obtain any of these items, such as the title or author, You need to obtain the whole article data and transmit a large amount of data. Next, deserialize and obtain the title. You can even store base64 images. The most common examples are user name, password, email address, and verification code. Maximum storage allowed for a string key512 MBData.

 SetKey value

Keys* List all keys, which are not recommended in the production environment.

KeysWildcard characters are supported.

Use*Match any (including 0) characters

Use[]Matching range

Use?Match any character. Note:"I"

There is another\ XEscape Character, which is used when the content with escape characters needs to be obtained.

 ExistsDetermine whether a number exists and return corresponding numbers

 DelThe keys deletion key deletes several numbers that are returned.

 TypeType of the key returned by the key

GetKey is only applicable to strings.

IncrThe key increments the number. If you use get set to implement the incr key, the competition will occur. For details, see my article on Redis concurrent lock. If the key that does not exist is 0 by default, the value after this command operation is 1, and the incremental value is returned.

IncrbyIf the specified value is added to the key, the added result is returned.

DecrAll decrby operations are subtraction.

 AppendKey val value, and returns the string length.

StrlenReturns the string length of the key value.

 MsetMget stores and obtains multiple key values at a time.

 

Summary: describes the basic string operations and results. Some other operations have never been used. The incr command is generally used for Document ID and access statistics, without concurrent competition.

In our habits, we name the Redis keyObject Type: Object ID: Object PropertyComeName.

For example: Artical: 4001: ViewCount Article 4001 visits Project: 1001: PM Project 1001 PM Book: 9001: Author. Name Book 9001 Author Name

 

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.