mirror of https://github.com/folke/lazy.nvim.git
feat(cache): make ttl configurable
This commit is contained in:
parent
9837d5be7e
commit
4aa362e8dc
|
@ -384,6 +384,7 @@ return {
|
||||||
-- * VimEnter: not useful to cache anything else beyond startup
|
-- * VimEnter: not useful to cache anything else beyond startup
|
||||||
-- * BufReadPre: this will be triggered early when opening a file from the command line directly
|
-- * BufReadPre: this will be triggered early when opening a file from the command line directly
|
||||||
disable_events = { "VimEnter", "BufReadPre" },
|
disable_events = { "VimEnter", "BufReadPre" },
|
||||||
|
ttl = 3600 * 24 * 5, -- keep unused modules for up to 5 days
|
||||||
},
|
},
|
||||||
reset_packpath = true, -- reset the package path to improve startup time
|
reset_packpath = true, -- reset the package path to improve startup time
|
||||||
rtp = {
|
rtp = {
|
||||||
|
|
|
@ -16,6 +16,7 @@ M.config = {
|
||||||
-- * VimEnter: not useful to cache anything else beyond startup
|
-- * VimEnter: not useful to cache anything else beyond startup
|
||||||
-- * BufReadPre: this will be triggered early when opening a file from the command line directly
|
-- * BufReadPre: this will be triggered early when opening a file from the command line directly
|
||||||
disable_events = { "VimEnter", "BufReadPre" },
|
disable_events = { "VimEnter", "BufReadPre" },
|
||||||
|
ttl = 3600 * 24 * 5, -- keep unused modules for up to 5 days
|
||||||
}
|
}
|
||||||
M.debug = false
|
M.debug = false
|
||||||
|
|
||||||
|
@ -27,7 +28,6 @@ local cache_hash
|
||||||
---@type table<string,CacheEntry?>
|
---@type table<string,CacheEntry?>
|
||||||
M.cache = {}
|
M.cache = {}
|
||||||
M.enabled = true
|
M.enabled = true
|
||||||
M.ttl = 3600 * 24 * 5 -- keep unused modules for up to 5 days
|
|
||||||
---@type string[]
|
---@type string[]
|
||||||
M.rtp = nil
|
M.rtp = nil
|
||||||
-- selene:allow(global_usage)
|
-- selene:allow(global_usage)
|
||||||
|
@ -238,7 +238,7 @@ function M.save_cache()
|
||||||
uv.fs_write(f, M.VERSION)
|
uv.fs_write(f, M.VERSION)
|
||||||
uv.fs_write(f, "\0")
|
uv.fs_write(f, "\0")
|
||||||
for modname, entry in pairs(M.cache) do
|
for modname, entry in pairs(M.cache) do
|
||||||
if entry.used > os.time() - M.ttl then
|
if entry.used > os.time() - M.config.ttl then
|
||||||
entry.modname = modname
|
entry.modname = modname
|
||||||
local header = {
|
local header = {
|
||||||
entry.hash.size,
|
entry.hash.size,
|
||||||
|
|
Loading…
Reference in New Issue