框架——緩存框架——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指令,停止服務器。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章