Changeset

8926:89f6b2a2bec3

MUC: Measure cache hits and misses
author Kim Alvefur <zash@zash.se>
date Sat, 23 Jun 2018 18:59:21 +0200
parents 8925:d367aeb9c50f
children 8927:ed0891383e78
files plugins/muc/mod_muc.lua
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/muc/mod_muc.lua	Sat Jun 23 18:58:56 2018 +0200
+++ b/plugins/muc/mod_muc.lua	Sat Jun 23 18:59:21 2018 +0200
@@ -135,6 +135,8 @@
 local max_rooms = module:get_option_number("muc_max_rooms");
 local max_live_rooms = module:get_option_number("muc_room_cache_size", 100);
 
+local room_hit = module:measure("room_hit", "rate");
+local room_miss = module:measure("room_miss", "rate")
 local room_eviction = module:measure("room_eviction", "rate");
 local rooms = cache.new(max_rooms or max_live_rooms, function (jid, room)
 	if max_rooms then
@@ -217,9 +219,11 @@
 function get_room_from_jid(room_jid)
 	local room = rooms:get(room_jid);
 	if room then
+		room_hit();
 		rooms:set(room_jid, room); -- bump to top;
 		return room;
 	end
+	room_miss();
 	return restore_room(room_jid);
 end