Redis Learning Notes (String Type Common command actions)

Source: Internet
Author: User

Redis string Types Common command operations Access data

To save the string type data:

Take string type data:

Returns NULL when the key is not present

If you repeatedly save data to a key, the stored data overwrites the previously stored data

Increment number

When the stored string is in integer form, Redis provides a:

INCR command: To increment the current key value and return the incremented value

When the key value to increment does not exist, Redis will automatically deposit this key, the default value is 0, and increment the value


Name of the key

The key name Redis is not mandatory, and the general naming form is:

Object type: Object ID: Object property

For example: User:1:name Use this to store the name of the user with ID 1

Generate a self-increment ID

For example, each user generated a unique ID, the relational database setting ID field auto_increment to achieve

Object types can be used in Redis: Count for example (Users:count) stores the number of current object types without adding a

A new object, use the INCR command to increment the value of the key. INCR the initial value of the key value is 1, so the return of the INCR command

The value represents the total number of objects after the object is deposited, and can be used as the ID of the object.

Increase the specified integer

Incrby and INCR commands are basically the same, Incrby can specify an incremented value once:

Decrease the specified integer

DECR can make the values decrement

Decrby can specify how many values to subtract

Increase the specified floating point number

Add value to Tail

Get string length

Simultaneous storage gets multiple keys

Bit operation (temporarily not understand)

Redis Learning Notes (String Type Common command actions)

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.