Browse Source

[Enhancement] Add expire to history redis

tags/3.3
Vitaliy Vasilenko 2 years ago
parent
commit
581ff8e565
No account linked to committer's email address
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      src/plugins/lua/history_redis.lua

+ 9
- 1
src/plugins/lua/history_redis.lua View File

@@ -21,6 +21,8 @@ if confighelp then
redis_history {
# History key name
key_prefix = 'rs_history';
# History expire in seconds
expire = 0;
# History rows limit
nrows = 200;
# Use zstd compression when storing data in redis
@@ -42,6 +44,7 @@ local redis_params

local settings = {
key_prefix = 'rs_history', -- default key name
expire = 0, -- default no expire
nrows = 200, -- default rows limit
compress = true, -- use zstd compression when storing data in redis
subject_privacy = false, -- subject privacy is off
@@ -153,7 +156,12 @@ local function history_save(task)

if ret then
conn:add_cmd('LTRIM', {prefix, '0', string.format('%d', settings.nrows-1)})
conn:add_cmd('SADD', {settings.key_prefix, prefix})

if settings.expire > 0 then
conn:add_cmd('EXPIRE', {prefix, string.format('%d', settings.expire)})
else
conn:add_cmd('SADD', {settings.key_prefix, prefix})
end
end
end


Loading…
Cancel
Save