Redis Data Type Summary-string

Source: Internet
Author: User

1.1 Data types

There are five data types used by Redis: string, hash, list, set, Zset (sorted set).

Redis internally uses a Redisobject object to represent all keys and value, redisobject the most important information as shown in

The type represents what data type a value object is, and encoding is how different data types are stored inside the Redis, such as: Type=string represents a normal string for value. Then the corresponding encoding can be raw or int, and if it is an int, the actual redis internal is stored and represented by a numeric class, assuming that the string itself can be represented numerically, such as a string such as "123" "456".

Open Redis source scr/sds.h See the structure of string type (note; The following are the source of redis-3.0)

Type is the corresponding 5 data types and is already defined.

1.1.1 String Type
    1. 1. String data type

The string is the simplest type, and a key corresponds to a value,string type of data up to 1G. A string type can be treated as an integer, allowing the "INCR" command family to operate (Incrby, DECR, Decrby), in which case the value of the integer is limited to 64-bit signed numbers. The separate element types contained in list, set, and Zset are Redis string types.

    1. 2. String data Structure

Open Redis Source Scr/sds.h View the structure of the string type

Len: The length of the tag char[] is somewhat similar to the size of the list in our C #.

Free: The number of unused elements in the tag char[] is the meaning of a few empty pits.

Buf[]: The hole that holds the element is not necessarily equal to the actual number of elements, such as the Cnblogs mentioned earlier. It may also be [c][n][b][l][o][g][s][/0][][][].

    1. 3. String data type common commands

Resids related commands can refer to the website information http://doc.redisfans.com/

Redis Data Type Summary-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.