Introduction to Redis Data types 1

Source: Internet
Author: User

Data type

Strings

The string is the most basic type of REDIS data. Redis strings are binary safe, which means that a Redis string can contain any type of data, such as a JPEG image or a serialized Ruby object.

A string can be up to 512M maximum.

You can use Redis strings to do a lot of interesting things, such as:
(1) can be used as an atomic counter. In conjunction with the INCR command: Incr,decr,incrby
(2) extending a string with the append command
(3) Random access to substrings using GetRange and SetRange commands
(4) Use the Getbit and Setbit commands to access the bits of the string

Lists

The Redis list stores strings in the order in which they are inserted. It supports insertion at the head and trailing inserts.

The Lpush command inserts a new element into the head, and Rpush inserts it at the tail. The list is created automatically when an element is inserted into an empty key. Similarly, if an operation clears the list

element, then key is also cleared. These are very handy syntax features because all list commands behave consistently when you perform an operation on a nonexistent key.

The following is an example of an operation performed on Lsit:
Lpush MyList A # Now the list is "a"
Lpush MyList B # Now the list is "B", "a"
Rpush MyList C # Now the list is "B", "A", "C"

Each list supports a maximum of 2 of 32 square-1 elements, or 4,294,967,295 elements.

In terms of time efficiency, the list supports the insertion or deletion of a constant time, even if it contains millions of elements. However, the elements in the middle of the list operate at an O (N) time.

Introduction to Redis Data types 1

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.