Redis Basic Learning (iv) Persistence of-redis

Source: Internet
Author: User

I. Overview

The power of Redis is largely due to the fact that the data is in memory, but when the Redis restarts, all the data stored in memory is lost, so we persist the data in memory.

Redis supports two ways to persist data: RDB mode and AOF mode.

(1) The Rdb method persists the in-memory data to the hard disk on a timed basis according to the configured rules.

(2) AOF the command after each execution of the write command.

1.RDB mode

The persistence of the RDB mode is done by means of a snapshot. When a rule is met, all in-memory data is generated in a single copy stored on the hard disk, and Redis snapshots the data in the following situations:

A: Automatic snapshots based on the configured rules.

B: The user executes the save, Bgsave command.

C: Execute the flushall command.

D: Perform replication (replication).

(1) Automatic snapshot according to configuration

Redis allows users to customize snapshot conditions and automatically perform snapshots when conditions are met, and the snapshot rules are configured as follows:

(2) Execute save, Bgsave command

We can manually perform the save, Bgsave command to take the snapshot operation proactively.

Save: When you execute the Save command, Redis synchronizes the snapshot operation, which blocks all requests from the client, so you should avoid using the command when you put more database data.

Bgsave: As can be seen from the command name, this command differs from the Save command in that the snapshot operation of the command is performed asynchronously in the background, while the snapshot operation can also handle requests from the client. After executing the bgsave command, Redis returns OK immediately to start the snapshot operation, and if you want to know if the snapshot operation is complete, you can use the Lasesave command to return the last time the snapshot was successfully executed, and the result is a UNIX timestamp.

Redis Basic Learning (iv) Persistence of-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.