Data types and how to set up Redis

Source: Internet
Author: User

1. Redis supports five types of data type strings (string), hash (hash), List (list), set (set), Zset (ordered set);

2. String is the most basic type of redis, a key can support storage 512MB;

Set name "Lanyulei"

Del name

Set a key that is name, and the corresponding value is a string of Lan Yulei

Get Name

Result set is "Lanyulei"

3. Redis Hash is a String type field and value mapping table, hash is especially suitable for storing objects

Hmset user username Lanyulei sex Mans age 25

Set a hash value, key is User,value is the form of an even number

Each hash can store 2 of the 32-1-square, key-value pairs (more than 4 billion)

4. Redis is a simple list of strings, sorted by insertion order, and you can add the head or tail of an element guide list.

Set a list type data named Lanyulei, and the contents are added and displayed in order

Lpush Lanyulei Redis

Lpush Lanyulei MongoDB

Lpush Lanyulei RABITMQ

The value,0 10 for this list "Lanyulei" is the data that is obtained before the subscript is 0 to 10

Lrange Lanyulei 0 10

5. Unordered Collection Creation

Set an unordered collection

Sadd Lanyulei Redis

Sadd Lanyulei MongoDB

Sadd Lanyulei MySQL

Sadd Lanyulei MySQL

Get the contents of this collection

Smembers Lanyulei

6. Creation of ordered collections

An ordered collection is also a collection of elements of type string, as well as a collection, and does not allow duplicate members.

The members of an ordered collection are unique, but fractions (score) can be duplicated.

Zadd Lanyulei Redis

Zadd Lanyulei MongoDB

Zadd Lanyulei MySQL

Zadd Lanyulei MySQL

Get the contents of this collection

Zmembers Lanyulei


Data types and how to set up Redis

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.