refactor: move fs-backed cache under WINDMILL_DIR (#8537)

* refactor: move fs-backed cache under WINDMILL_DIR

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: add WINDMILL_CACHE_PREFIX env var for per-session cache isolation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: auto-use WEBMUX_BRANCH as cache prefix for session isolation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-03-26 08:58:50 +00:00
committed by GitHub
parent 6620f5513c
commit cc67fd9e46
+7 -8
View File
@@ -41,15 +41,14 @@ pub use quick_cache::sync::Cache;
#[cfg(not(feature = "scoped_cache"))]
lazy_static! {
/// Cache directory for windmill server/worker(s).
/// 1. If `XDG_CACHE_HOME` is set, use `"${XDG_CACHE_HOME}/windmill"`.
/// 2. If `HOME` is set, use `"${HOME}/.cache/windmill"`.
/// 3. Otherwise, use `"{std::env::temp_dir()}/windmill/cache"`.
/// Lives under `WINDMILL_DIR` (default `/tmp/windmill`) as `cache_db/`.
/// If `WINDMILL_CACHE_PREFIX` (or `WEBMUX_BRANCH`) is set, uses `cache_db/{prefix}/`.
pub static ref CACHE_PATH: PathBuf = {
std::env::var("XDG_CACHE_HOME")
.map(PathBuf::from)
.or_else(|_| std::env::var("HOME").map(|home| PathBuf::from(home).join(".cache")))
.map(|cache| cache.join("windmill"))
.unwrap_or_else(|_| std::env::temp_dir().join("windmill/cache"))
let base = PathBuf::from(&*crate::worker::WINDMILL_DIR).join("cache_db");
let prefix = std::env::var("WINDMILL_CACHE_PREFIX")
.or_else(|_| std::env::var("WEBMUX_BRANCH"))
.unwrap_or_default();
if prefix.is_empty() { base } else { base.join(prefix) }
};
}