• 框架——缓存框架——redis——功能——脚本


      只介绍一些概念,其他略。

    1、只读脚本

      在脚本上添加no-writes flag之后,为只读脚本,它的特点如下:

    They can always be executed on replicas.

    可以在从服务器上执行。

    They can always be killed by the SCRIPT KILL command

    可以被SCRIPT KILL命令杀掉。

    They never fail with OOM error when redis is over the memory limit.

    不存在内存溢出的问题

    They are not blocked during write pauses, such as those that occur during coordinated failovers.

    在有进程在写操作时,也不会被阻塞。

    They cannot execute any command that may modify the data set.

    不能修改任何数据

    Currently PUBLISH, SPUBLISH and PFCOUNT are also considered write commands in scripts, because they could attempt to propagate commands to replicas and AOF file.

    对AOF文件存在写操作也不被允许,例如PUBLISH, SPUBLISH, PFCOUNT等命令。

    2、设置脚本执行时间

    设置方式:

    设置busy-reply-threshold参数。

    脚本超过最长时间之后的场景:

    引用原著:

      Redis logs that a script is running for too long.

    记录日志。

      It starts accepting commands again from other clients but will reply with a BUSY error to all the clients sending normal commands. The only commands allowed in this state are SCRIPT KILL, FUNCTION KILL, and SHUTDOWN NOSAVE.

    任何其他客户端的命令,响应内容都是busy 错误。

      It is possible to terminate a script that only executes read-only commands using the SCRIPT KILL and FUNCTION KILL commands. These commands do not violate the scripting semantic as no data was written to the dataset by the script yet.

    若是只读脚本,则可以使用SCRIPT KILL和 FUNCTION KILL命令结束脚本的运行。

    If the script had already performed even a single write operation, the only command allowed is SHUTDOWN NOSAVE that stops the server without saving the current data set on disk (basically, the server is aborted).

    不是只读脚本,若脚本造成了修改,只能执行SHUTDOWN NOSAVE指令,停止服务器。

  • 相关阅读:
    shell基础知识8-xargs命令
    shell基础知识7-字段分隔符与迭代器
    shell基础知识6-在不按回车键的情况下读入N个字符
    DevOps
    DevOps
    Jenkins
    Jenkins
    Jenkins
    Jenkins
    Gerrit
  • 原文地址:https://www.cnblogs.com/rain144576/p/16792926.html
Copyright © 2020-2023  润新知