Comparison

plugins/mod_smacks.lua @ 11980:a91494a4c3d0

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.
author Kim Alvefur <zash@zash.se>
date Wed, 01 Dec 2021 23:03:11 +0100
parent 11979:705c4c07a860
child 11981:5d8264f464a2
comparison
equal deleted inserted replaced
11979:705c4c07a860 11980:a91494a4c3d0
68 if not user then return nil; end 68 if not user then return nil; end
69 if not key then return nil; end 69 if not key then return nil; end
70 if not stores[user] then stores[user] = cache.new(max_entries, evict_callback); end 70 if not stores[user] then stores[user] = cache.new(max_entries, evict_callback); end
71 stores[user]:set(key, value); 71 stores[user]:set(key, value);
72 -- remove empty caches completely 72 -- remove empty caches completely
73 if not stores[user]:count() then stores[user] = nil; end 73 if stores[user]:count() == 0 then stores[user] = nil; end
74 end; 74 end;
75 }; 75 };
76 end 76 end
77 local old_session_registry = init_session_cache(max_old_sessions, nil); 77 local old_session_registry = init_session_cache(max_old_sessions, nil);
78 local session_registry = init_session_cache(max_hibernated_sessions, function(resumption_token, session) 78 local session_registry = init_session_cache(max_hibernated_sessions, function(resumption_token, session)