Skip to content

Commit 4aa362e

Browse files
committed
feat(cache): make ttl configurable
1 parent 9837d5b commit 4aa362e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ return {
384384
-- * VimEnter: not useful to cache anything else beyond startup
385385
-- * BufReadPre: this will be triggered early when opening a file from the command line directly
386386
disable_events = { "VimEnter", "BufReadPre" },
387+
ttl = 3600 * 24 * 5, -- keep unused modules for up to 5 days
387388
},
388389
reset_packpath = true, -- reset the package path to improve startup time
389390
rtp = {

lua/lazy/core/cache.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ M.config = {
1616
-- * VimEnter: not useful to cache anything else beyond startup
1717
-- * BufReadPre: this will be triggered early when opening a file from the command line directly
1818
disable_events = { "VimEnter", "BufReadPre" },
19+
ttl = 3600 * 24 * 5, -- keep unused modules for up to 5 days
1920
}
2021
M.debug = false
2122

@@ -27,7 +28,6 @@ local cache_hash
2728
---@type table<string,CacheEntry?>
2829
M.cache = {}
2930
M.enabled = true
30-
M.ttl = 3600 * 24 * 5 -- keep unused modules for up to 5 days
3131
---@type string[]
3232
M.rtp = nil
3333
-- selene:allow(global_usage)
@@ -238,7 +238,7 @@ function M.save_cache()
238238
uv.fs_write(f, M.VERSION)
239239
uv.fs_write(f, "\0")
240240
for modname, entry in pairs(M.cache) do
241-
if entry.used > os.time() - M.ttl then
241+
if entry.used > os.time() - M.config.ttl then
242242
entry.modname = modname
243243
local header = {
244244
entry.hash.size,

0 commit comments

Comments
 (0)