Comparison

mod_http_oauth2/mod_http_oauth2.lua @ 5625:869c01d91aea

mod_http_oauth2: Clean cache less frequently Seems unlikely that enough unused and expired codes accumulate to warrant an hourly job.
author Kim Alvefur <zash@zash.se>
date Mon, 24 Jul 2023 01:26:41 +0200
parent 5624:d8622797e315
child 5626:81042c2a235a
comparison
equal deleted inserted replaced
5624:d8622797e315 5625:869c01d91aea
214 214
215 local codes = cache.new(10000, function (_, code) 215 local codes = cache.new(10000, function (_, code)
216 return code_expired(code) 216 return code_expired(code)
217 end); 217 end);
218 218
219 -- Periodically clear out unredeemed codes. Does not need to be exact, expired 219 -- Clear out unredeemed codes so they don't linger in memory.
220 -- codes are rejected if tried. Mostly just to keep memory usage in check. 220 module:daily("Clear expired authorization codes", function()
221 module:hourly("Clear expired authorization codes", function()
222 local k, code = codes:tail(); 221 local k, code = codes:tail();
223 while code and code_expired(code) do 222 while code and code_expired(code) do
224 codes:set(k, nil); 223 codes:set(k, nil);
225 k, code = codes:tail(); 224 k, code = codes:tail();
226 end 225 end