5 Primary data types and commands for Redis

Source: Internet
Author: User

Redis is a database of key-value pairs with 5 of the primary data types :

String type (string), hash type (hash), list type (lists), collection type (set), Ordered collection type (zset)

One: String type

The string type is the most basic type of redis, and it can store any form of string. The other four types are different forms of string types.

The most basic command: GET, SET Syntax: GET Key,set Key value value if there are spaces that need double quotation marks to differentiate

Integer increment: INCR syntax: INCR key default value is 0, so first execute command get 1, not integer hint error

Add the specified integer: Incrby syntax: Incrby key increment

Integer decrement: DECR syntax: DECR key default value is 0, so first execute command get-1, not integral type hint error

Decrease the specified integer: Decrby syntax: Decrby key increment

Add a specified floating point number: Incrbyfloat syntax: Incrbyfloat key increment is similar to the INCR command, except that you can increment a double-precision floating-point number

Append value to Tail: APPEND Syntax: APPEND key value The Redis client is not the output appended string, but the total length of the output string

Get string Length: STRLEN syntax: STRLEN key if the key does not exist return 0, note that if there is Chinese, a Chinese length is 3,redis is used UTF-8 encoded Chinese

Get multiple Key values: MGET syntax: MGET key [key ...] Example: MGET key1 Key2

Set multiple key values: MSET syntax: MSET key value [key value ...] Example: MSET key1 1 Key2 "Hello Redis"

Multiple Redis commands, recorded for forgetting

5 Primary data types and commands for 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.