From 7182a72911b677f951facf49ebe01c8ab4fa7376 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 1 Dec 2021 23:03:11 +0100 Subject: mod_smacks: Fix empty cache check In Lua, every value except `nil` and `false` are considered true in boolean expressions, even `0` as here, which means this was dead code. --- plugins/mod_smacks.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_smacks.lua b/plugins/mod_smacks.lua index f6fecdb2..53ef87b3 100644 --- a/plugins/mod_smacks.lua +++ b/plugins/mod_smacks.lua @@ -70,7 +70,7 @@ local function init_session_cache(max_entries, evict_callback) if not stores[user] then stores[user] = cache.new(max_entries, evict_callback); end stores[user]:set(key, value); -- remove empty caches completely - if not stores[user]:count() then stores[user] = nil; end + if stores[user]:count() == 0 then stores[user] = nil; end end; }; end -- cgit v1.2.3