Add configurable memory limits and LRU eviction for runtime cache

This commit is contained in:
truewhile
2026-09-13 00:41:04 +08:00
parent 2989649445
commit 386fc358d1
13 changed files with 634 additions and 93 deletions
+16
View File
@@ -119,6 +119,22 @@ func ApplyRuntimeSetting(cfg *config.Config, key, value string) {
}
cfg.Cache.ImagesMaxSizeMB = n
}
case "cache.memory_max_size_mb":
n := config.DefaultCacheMemoryMaxSizeMB
if value != "" {
parsed, err := strconv.Atoi(value)
if err != nil {
return
}
n = parsed
}
if n <= 0 {
n = config.DefaultCacheMemoryMaxSizeMB
}
if n > 4096 {
n = 4096
}
cfg.Cache.MemoryMaxSizeMB = n
}
}