Changeset

11491:c3fb802f9e45

mod_http_file_share: Report number of items in caches to statsmanager This is neat, O(1) reporting, why don't we do this everywhere? Gives you an idea of how much stuff is in the caches, which may help inform decisions on whether the size is appropriate.
author Kim Alvefur <zash@zash.se>
date Sun, 28 Mar 2021 13:15:11 +0200
parents 11490:34d4e4a01ef8
children 11492:6da8d9cb355d
files plugins/mod_http_file_share.lua
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_http_file_share.lua	Tue Mar 16 02:44:22 2021 +0100
+++ b/plugins/mod_http_file_share.lua	Sun Mar 28 13:15:11 2021 +0200
@@ -62,6 +62,14 @@
 local upload_cache = cache.new(1024);
 local quota_cache = cache.new(1024);
 
+local measure_upload_cache_size = module:measure("upload_cache", "amount");
+local measure_quota_cache_size = module:measure("quota_cache", "amount");
+
+module:hook_global("stats-update", function ()
+	measure_upload_cache_size(upload_cache:count());
+	measure_quota_cache_size(quota_cache:count());
+end);
+
 local measure_uploads = module:measure("upload", "sizes");
 
 -- Convenience wrapper for logging file sizes