Understanding redis (I)

Source: Internet
Author: User
Mind Map

As mentioned above, I am doing data synchronization for Douban. Now the synchronization operation has been completed, and the problem is reading. The reason for using redis is that there is not enough MySQL server to support my business. The boss means to hand over the pressure to redis, mainly in terms of efficiency. The general architecture is like this.

Official website for information: http://redis.io/documentation Book-2011-Tiago Macedo-redis cookbook Redis-the road to redis big data-Tang Fulin redis practices-operations on Hongwan Production

Prepare and install

 

Go to the src directory to start the service:

Looks good.

Next we will link it on the client.

Redis treats all values as character arrays, regardless of what it is.

 

Character query:

 

Data Structure

 

Strings:

It is interpreted as the same type as memcached. A key corresponds to a value, and the operations on it are similar to those on memcached.

View the commands on my terminal: (get key is an operation to obtain the corresponding value)

 

Hashes:

Hash is particularly suitable for Object Storage. Storing an object in the hash type consumes less memory and makes it easier to store the entire object. If the value size exceeds the limit, redis will automatically replace zipmap with a normal hash internally.

 

View my operations:

 

Lists:

Lists is a two-way linked list structure. The key in the operation is interpreted as the name of the linked list. -- Can be used as a stack or a queue.

Note: The length of lists is limited. The maximum length is 2 to the power of 32.

 

 

Sets

Set is a set-the main operation. When performing operations such as intersection and other operations on multiple sets, the key is interpreted as the Set Name.

Set is also implemented through hash table.

 

Sorted sets:

It is an upgraded version of set, and its implementation is a mixture of Skip List and hash table.

 

Common commands Return key value: Keys Returns all keys that satisfy the given pattern. The second parameter must exist. If no, an error is returned.

 

Check whether the key exists: exists

Delete A key: del

Set an expiration time: expire (unit: seconds)

 

Rename key: Rename

 

Return Value Type: Type

This is just a basic article, that is, getting familiar with redis. The key point is to understand the five infrastructures, to understand the advantages and disadvantages of each structure, and to select an appropriate data structure for different businesses. -- I will use the hash structure myself. Also, table jumping is a popular data structure. If you are not familiar with it, take some time to get familiar with it. I used it for the first time. If you have any mistakes, please give us some advice. Recommendation
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.