Test the existing Redis Data Structure

Source: Internet
Author: User
Redis supports the following data structures: strings, lists, hashes, set, and sortedset. The following are specific operations for strings: getsetsetnx, append,

Data Structures Supported by redis: strings, lists, hashes, set, sorted set. The specific operations for strings are as follows: get/set/setnx, append,

Data Structures Supported by redis: strings, lists, hashes, set, sorted set. Next we will do the experiment one by one.

Strings operations include get/set/setnx, append, strlen, getrange/setrange, incr/decr/incrby/decrby, mget/mset.

Get/set is to insert data (key-value corresponds ):

Setnx is used to insert data to check whether the same key value exists. If yes, 0 is returned. If no value exists, 1: append is returned, which is a simple append character: getrange/setrange is a simple string operation that retrieves or sets the character at the relative position. There was a problem during the experiment here, mainly because we were not familiar with the setrange operation. Let's take a look at the following operation and we will understand that setrange is used to replace the number of corresponding positions, the location of 5 is @, and QQ.com is 6 characters to replace mysina. com10 characters can only Replace the first six. Incr/decr/incrby/decrby means that the incrby/decrby after auto-increment and auto-subtraction are added with the step size. If there is no key value, it can also be operated: mget/mset indicates batch insertion and removal.

The basic operations of a hash table are the same as those of a string, such as hget/hset/hsetnx, happend, hstrlen, hgetrange/hsetrange, hincr/hdecr/hincrby/hdecrby, and hmet/hmset, just add H to the front. It is especially suitable for storing object data. The basic operation is the same as above. Here the key is used as the hash name. During the operation, you need to provide the hash field you want to insert:

Other operations are the same as above:

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.