Software /
code /
prosody
Comparison
plugins/mod_http_file_share.lua @ 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 |
parent | 11406:9d6545a7d483 |
child | 11493:77f2d45799ed |
comparison
equal
deleted
inserted
replaced
11490:34d4e4a01ef8 | 11491:c3fb802f9e45 |
---|---|
59 quota = { type = "wait"; condition = "resource-constraint"; text = "Daily quota reached"; }; | 59 quota = { type = "wait"; condition = "resource-constraint"; text = "Daily quota reached"; }; |
60 }); | 60 }); |
61 | 61 |
62 local upload_cache = cache.new(1024); | 62 local upload_cache = cache.new(1024); |
63 local quota_cache = cache.new(1024); | 63 local quota_cache = cache.new(1024); |
64 | |
65 local measure_upload_cache_size = module:measure("upload_cache", "amount"); | |
66 local measure_quota_cache_size = module:measure("quota_cache", "amount"); | |
67 | |
68 module:hook_global("stats-update", function () | |
69 measure_upload_cache_size(upload_cache:count()); | |
70 measure_quota_cache_size(quota_cache:count()); | |
71 end); | |
64 | 72 |
65 local measure_uploads = module:measure("upload", "sizes"); | 73 local measure_uploads = module:measure("upload", "sizes"); |
66 | 74 |
67 -- Convenience wrapper for logging file sizes | 75 -- Convenience wrapper for logging file sizes |
68 local function B(bytes) return hi.format(bytes, "B", "b"); end | 76 local function B(bytes) return hi.format(bytes, "B", "b"); end |