From ba81df22660c5fafeaf45296281c23ed7359c0b3 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Mon, 22 Sep 2025 16:50:14 -0400 Subject: [PATCH] fix(cache): expiry --- lua/cp/cache.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/cp/cache.lua b/lua/cp/cache.lua index dbfb160..d2ec4f2 100644 --- a/lua/cp/cache.lua +++ b/lua/cp/cache.lua @@ -54,6 +54,10 @@ local function is_cache_valid(contest_data, platform) platform = { platform, 'string' }, }) + if contest_data.expires_at and os.time() >= contest_data.expires_at then + return false + end + return true end @@ -129,9 +133,11 @@ function M.set_contest_data(platform, contest_id, problems) cache_data[platform] = {} end + local ttl = CONTEST_LIST_TTL[platform] or (24 * 60 * 60) cache_data[platform][contest_id] = { problems = problems, scraped_at = os.date('%Y-%m-%d'), + expires_at = os.time() + ttl, } M.save()