Software /
code /
prosody
Comparison
plugins/muc/mod_muc.lua @ 8926:89f6b2a2bec3
MUC: Measure cache hits and misses
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 23 Jun 2018 18:59:21 +0200 |
parent | 8925:d367aeb9c50f |
child | 8944:200ec7d38a0e |
comparison
equal
deleted
inserted
replaced
8925:d367aeb9c50f | 8926:89f6b2a2bec3 |
---|---|
133 end | 133 end |
134 | 134 |
135 local max_rooms = module:get_option_number("muc_max_rooms"); | 135 local max_rooms = module:get_option_number("muc_max_rooms"); |
136 local max_live_rooms = module:get_option_number("muc_room_cache_size", 100); | 136 local max_live_rooms = module:get_option_number("muc_room_cache_size", 100); |
137 | 137 |
138 local room_hit = module:measure("room_hit", "rate"); | |
139 local room_miss = module:measure("room_miss", "rate") | |
138 local room_eviction = module:measure("room_eviction", "rate"); | 140 local room_eviction = module:measure("room_eviction", "rate"); |
139 local rooms = cache.new(max_rooms or max_live_rooms, function (jid, room) | 141 local rooms = cache.new(max_rooms or max_live_rooms, function (jid, room) |
140 if max_rooms then | 142 if max_rooms then |
141 module:log("info", "Room limit of %d reached, no new rooms allowed"); | 143 module:log("info", "Room limit of %d reached, no new rooms allowed"); |
142 return false; | 144 return false; |
215 end | 217 end |
216 | 218 |
217 function get_room_from_jid(room_jid) | 219 function get_room_from_jid(room_jid) |
218 local room = rooms:get(room_jid); | 220 local room = rooms:get(room_jid); |
219 if room then | 221 if room then |
222 room_hit(); | |
220 rooms:set(room_jid, room); -- bump to top; | 223 rooms:set(room_jid, room); -- bump to top; |
221 return room; | 224 return room; |
222 end | 225 end |
226 room_miss(); | |
223 return restore_room(room_jid); | 227 return restore_room(room_jid); |
224 end | 228 end |
225 | 229 |
226 function create_room(room_jid, config) | 230 function create_room(room_jid, config) |
227 local exists = get_room_from_jid(room_jid); | 231 local exists = get_room_from_jid(room_jid); |