redis持久化-純緩存模式
文檔
- redis單機安裝
- redis常用的五種數據類型
- redis數據類型-位圖bitmap
- redis數據類型-基數統計HyperLogLog
- redis數據類型-地理空間GEO
- redis數據類型-流Stream
- redis數據類型-位域bitfield
- redis持久化-RDB
- redis持久化-AOF
- redis持久化-RDB+AOF混合模式
官方文檔
- 官網操作命令指南頁面:https://redis.io/docs/latest/commands/?name=get&group=string
- Redis persistence
說明
- redis版本:7.0.0
純緩存模式
支持No persistence
模式
-
官方說明:Redis persistence
Persistence refers to the writing of data to durable storage, such as a solid-state disk (SSD). Redis provides a range of persistence options. These include:
- RDB (Redis Database): RDB persistence performs point-in-time snapshots of your dataset at specified intervals.
- AOF (Append Only File): AOF persistence logs every write operation received by the server. These operations can then be replayed again at server startup, reconstructing the original dataset. Commands are logged using the same format as the Redis protocol itself.
- No persistence: You can disable persistence completely. This is sometimes used when caching.
- RDB + AOF: You can also combine both AOF and RDB in the same instance.
禁用RDB持久化
-
找到啟動服務使用的配置文件,通常將安裝目錄下的
redis.conf
復制到指定路徑做為啟動文件,下面是配置文件中SNAPSHOTTING
配置的相關介紹################################ SNAPSHOTTING ################################# Save the DB to disk. # # save <seconds> <changes> [<seconds> <changes> ...] # # Redis will save the DB if the given number of seconds elapsed and it # surpassed the given number of write operations against the DB. # # Snapshotting can be completely disabled with a single empty string argument # as in following example: # # save "" # # Unless specified otherwise, by default Redis will save the DB: # * After 3600 seconds (an hour) if at least 1 change was performed # * After 300 seconds (5 minutes) if at least 100 changes were performed # * After 60 seconds if at least 10000 changes were performed # # You can set these explicitly by uncommenting the following line. # # save 3600 1 300 100 60 10000save ""
-
根據規則,可以使用單個空字符串參數完全禁用快照,即
save ""
-
RDB持久化模式默認是開啟的,需將配置手動調整為
save ""
-
修改后重啟redis
-
禁用RDB持久化是禁用了自動觸發,仍然可以使用
SAVE
、BGSAVE
等命令手動生成rdb文件
禁用AOF持久化
-
找到啟動服務使用的配置文件,通常將安裝目錄下的
redis.conf
復制到指定路徑做為啟動文件,下面是配置文件中APPEND ONLY MODE
配置的相關介紹############################## APPEND ONLY MODE ################################ By default Redis asynchronously dumps the dataset on disk. This mode is # good enough in many applications, but an issue with the Redis process or # a power outage may result into a few minutes of writes lost (depending on # the configured save points). # # The Append Only File is an alternative persistence mode that provides # much better durability. For instance using the default data fsync policy # (see later in the config file) Redis can lose just one second of writes in a # dramatic event like a server power outage, or a single write if something # wrong with the Redis process itself happens, but the operating system is # still running correctly. # # AOF and RDB persistence can be enabled at the same time without problems. # If the AOF is enabled on startup Redis will load the AOF, that is the file # with the better durability guarantees. # # Please check https://redis.io/topics/persistence for more information.appendonly no
-
appendonly
設置為no
,表示禁用AOF持久化,默認值即為no
-
AOF持久化模式默認是禁用的
-
修改后重啟redis