feat(cache): optimize cache loading
This commit is contained in:
parent
b219633fc1
commit
c540ba3050
1 changed files with 7 additions and 0 deletions
|
|
@ -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()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue