feat(cache): optimize cache loading

This commit is contained in:
Barrett Ruth 2025-09-19 20:44:45 -04:00
parent b219633fc1
commit c540ba3050

View file

@ -61,14 +61,20 @@ local function is_cache_valid(contest_data, platform)
end end
function M.load() function M.load()
if loaded then
return
end
if vim.fn.filereadable(cache_file) == 0 then if vim.fn.filereadable(cache_file) == 0 then
cache_data = {} cache_data = {}
loaded = true
return return
end end
local content = vim.fn.readfile(cache_file) local content = vim.fn.readfile(cache_file)
if #content == 0 then if #content == 0 then
cache_data = {} cache_data = {}
loaded = true
return return
end end
@ -78,6 +84,7 @@ function M.load()
else else
cache_data = {} cache_data = {}
end end
loaded = true
end end
function M.save() function M.save()