zoukankan      html  css  js  c++  java
  • Redis备份及回收策略

    Redis备份(持久化)

    Redis备份存在两种方式:

    • 1.一种是"RDB"。是快照(snapshotting),它是备份当前瞬间Redis在内存中的数据记录;
    • 2.另一种是"AOF"。只追加文件(Append-Only File,AOF),其作用是当Redis执行写命令后,在一定的条件下将执行过的写命令依次保存在Redis的文件中,将来就可以依次执行那些保存的命令恢复Redis的数据。

    对于快照备份而言,如果当前Redis数据量大,备份可能会造成卡顿,但是恢复重启比较快速。

    对于AOF备份,则相反。

    Redis内存回收策略

    Redis也会因为内存不足而出错,也可能因为回收过久而导致系统长期的停顿,因此需要执行回收策略。

    Redis允许配置6种回收策略,在内存达到最大时,将会淘汰键值,并进行回收。

    # MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
    # is reached. You can select among five behaviors:
    # 
    # volatile-lru -> remove the key with an expire set using an LRU algorithm
    # allkeys-lru -> remove any key according to the LRU algorithm
    # volatile-random -> remove a random key with an expire set
    # allkeys-random -> remove a random key, any key
    # volatile-ttl -> remove the key with the nearest expire time (minor TTL)
    # noeviction -> don't expire at all, just return an error on write operations

    内存回收策略如下:

    volatile-lru :采用LRU算法(最近最少使用算法),但是只淘汰超时的键值对。
     allkeys-lru :采用LRU算法,淘汰键值对。
     volatile-random :采用随机淘汰策略,但是只淘汰超时的键值对。
     allkeys-random :采用随机淘汰策略,淘汰键值对。
     volatile-ttl  :采用TTL算法(生存周期),淘汰存活时间最短的键值对。
     noeviction :不淘汰任何键值对,内存已满时,进行写操作返回错误。

    参考资料:

    《SSM框架和Redis实现》

  • 相关阅读:
    EasyUI
    intellij idea打包maven项目
    struts2框架详解
    java电子书
    查看mysql安装路径
    springboot 集成 vue
    C#中的属性
    C#中的时间戳
    int.TryParse非预期执行引发的思考
    IQueryable 和 IEnumerable 的区别
  • 原文地址:https://www.cnblogs.com/expiator/p/9871282.html
Copyright © 2011-2022 走看看