comparison mod_presence_cache/mod_presence_cache.lua @ 2153:aa24d49c47ef

mod_presence_cache: Only check set set is empty if it exists
author Kim Alvefur <zash@zash.se>
date Sun, 03 Apr 2016 00:55:53 +0200
parents bb4a2e4b7ba7
children cc0cf6748885
comparison
equal deleted inserted replaced
2152:bb4a2e4b7ba7 2153:aa24d49c47ef
14 local full_jid = cache_key:match("%z(.*)$"); 14 local full_jid = cache_key:match("%z(.*)$");
15 local jids = bare_cache[bare_cache_key]; 15 local jids = bare_cache[bare_cache_key];
16 16
17 if jids then 17 if jids then
18 jids[full_jid] = nil; 18 jids[full_jid] = nil;
19 end 19 if next(jids) == nil then
20 if next(jids) == nil then 20 bare_cache[bare_cache_key] = nil;
21 bare_cache[bare_cache_key] = nil; 21 end
22 end 22 end
23 end 23 end
24 24
25 -- used indirectly for the on_evict callback 25 -- used indirectly for the on_evict callback
26 local presence_cache = cache.new(cache_size, on_evict); 26 local presence_cache = cache.new(cache_size, on_evict);