diff options
| author | banjiaojuhao <banjiaojuhao@qq.com> | 2022-02-15 20:54:57 +0800 |
|---|---|---|
| committer | banjiaojuhao <banjiaojuhao@qq.com> | 2022-02-15 20:54:57 +0800 |
| commit | b5ec3467003b2becca9a91f9cf56ab6b24ede25e (patch) | |
| tree | 8f6ec607ec7311720c6e56bfefc2fa7fa955ee0b /weed/filer/redis_lua/stored_procedure/insert_entry.lua | |
| parent | 17ac5244c31d06f7065bd8ed9a416d00e048b23c (diff) | |
| download | seaweedfs-b5ec3467003b2becca9a91f9cf56ab6b24ede25e.tar.xz seaweedfs-b5ec3467003b2becca9a91f9cf56ab6b24ede25e.zip | |
FilerStore: add redis_lua
Diffstat (limited to 'weed/filer/redis_lua/stored_procedure/insert_entry.lua')
| -rw-r--r-- | weed/filer/redis_lua/stored_procedure/insert_entry.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/weed/filer/redis_lua/stored_procedure/insert_entry.lua b/weed/filer/redis_lua/stored_procedure/insert_entry.lua new file mode 100644 index 000000000..8deef3446 --- /dev/null +++ b/weed/filer/redis_lua/stored_procedure/insert_entry.lua @@ -0,0 +1,27 @@ +-- KEYS[1]: full path of entry +local full_path = KEYS[1] +-- KEYS[2]: dir of the entry +local dir_list_key = KEYS[2] + +-- ARGV[1]: content of the entry +local entry = ARGV[1] +-- ARGV[2]: TTL of the entry +local ttlSec = tonumber(ARGV[2]) +-- ARGV[3]: isSuperLargeDirectory +local isSuperLargeDirectory = ARGV[3] == "1" +-- ARGV[4]: zscore of the entry in zset +local zscore = tonumber(ARGV[4]) +-- ARGV[5]: name of the entry +local name = ARGV[5] + +if ttlSec > 0 then + redis.call("SET", full_path, entry, "EX", ttlSec) +else + redis.call("SET", full_path, entry) +end + +if not isSuperLargeDirectory and name ~= "" then + redis.call("ZADD", dir_list_key, "NX", zscore, name) +end + +return 0
\ No newline at end of file |
