redis必殺命令 指令碼

2021-08-07 01:27:09 字數 1146 閱讀 2483

redis 指令碼使用 lua 直譯器來執行指令碼。 reids 2.6 版本通過內嵌支援 lua 環境。執行指令碼的常用命令為 eval。

語法

redis 127.0

.0.1:6379> eval script numkeys key [key ...] arg [arg ...]

例如:

127.0

.0.1:6379> eval

"return "

2 key1 key2 first second

(error) err

error running script (call

to f_56424a2e6d8c042760d06de310ad266efa76d55d): @enable_strict_lua:15: user_script:1: script attempted to access unexisting global variable 'key'

127.0

.0.1:6379> eval

"return "

2 key1 key2 first second

1) "key1"

2) "key2"

3) "first"

4) "second"

127.0

.0.1:6379>

指令碼命令:

序號  命令及描述

1 eval script numkeys key [key ...] arg [arg ...] 執行 lua 指令碼。

2 evalsha sha1 numkeys key [key ...] arg [arg ...] 執行 lua 指令碼。

3 script exists script [script ...] 檢視指定的指令碼是否已經被儲存在快取當中。

4 script flush 從指令碼快取中移除所有指令碼。

5 script kill 殺死當前正在執行的 lua 指令碼。

6 script load script 將指令碼 script 新增到指令碼快取中,但並不立即執行這個指令碼。

redis必殺命令 HyperLogLog

redis 在 2.8.9 版本新增了 hyperloglog 結構。redis hyperloglog 是用來做基數統計的演算法,hyperloglog 的優點是,在輸入元素的數量或者體積非常非常大時,計算基數所需的空間總是固定 的 並且是很小的。在 redis 裡面,每個 hyperloglog...

redis必殺命令 雜湊 Hash

題記 redis hash 是乙個string型別的field和value的對映表,hash特別適合用於儲存物件。redis 中每個 hash 可以儲存 232 1 鍵值對 40多億 例如 127.0.0.1 6379 hmset xiongben name 王棟 desc 今年24歲 likes ...

redis必殺命令 列表 List

redis列表是簡單的字串列表,按照插入順序排序。你可以新增乙個元素導列表的頭部 左邊 或者尾部 右邊 乙個列表最多可以包含 232 1 個元素 4294967295,每個列表超過40億個元素 例如 wd wd usr local bin redis cli 127.0.0.1 6379 lpush...