Handles empty preferences only in the in-memory cache

This commit is contained in:
Simone Mainardi 2018-09-04 15:27:44 +02:00
parent 005335673f
commit f68e907dc1
2 changed files with 16 additions and 1 deletions

View file

@ -25,12 +25,23 @@ function prefs_dump_utils.savePrefsToDisk()
local out = {}
for _, pattern in pairs(patterns) do
-- ntop.getKeysCache returns all the redis keys
-- matching the given patter and SKIPS the in-memory
-- cache implemented in class Redis.
local keys = ntop.getKeysCache(pattern)
for k in pairs(keys or {}) do
local dump = ntop.dumpCache(k)
if dump ~= empty_string_dump then
out[k] = dump
elseif pattern == "ntopng.prefs.*" then
-- Empty preferences can be found in redis due to
-- previous implementations. Currently, empty preferences
-- only stay in the in-memory cache implemented in class Redis
-- (Redis::addToCache) and there's no longer need to have them
-- written to redis. See Redis::isCacheable for the whole list
-- of keys that are cached internally
ntop.delCache(k)
end
end
end