diff --git a/Cargo.lock b/Cargo.lock index 3d2dd4c..41195be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3596,6 +3596,7 @@ dependencies = [ "clap", "clap_complete", "clap_complete_fig", + "comemo", "env_logger", "handlebars", "include_dir", diff --git a/Cargo.toml b/Cargo.toml index d3f5b94..2a94d21 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ handlebars = "4.3" # general anyhow = "1" +comemo = "0.3" tokio = { version = "1.28.1", features = ["full"] } # cryptography and processing diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 4a610bd..d2b7ac6 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -26,7 +26,7 @@ clap.workspace = true clap_complete.workspace = true clap_complete_fig.workspace = true -# comemo.workspace = true +comemo.workspace = true # chrono.workspace = true tokio.workspace = true include_dir.workspace = true diff --git a/cli/src/main.rs b/cli/src/main.rs index cbc76e5..aa0bc99 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -174,6 +174,9 @@ pub async fn serve(args: ServeArgs) -> ZResult<()> { // Build the book if it hasn't been built yet if !args.no_build { proj.build()?; + + // since we don't need the compilation cache anymore, we can evict it + comemo::evict(0); } let http_addr: SocketAddr = args diff --git a/cli/src/project.rs b/cli/src/project.rs index 61f6263..a6ba68e 100644 --- a/cli/src/project.rs +++ b/cli/src/project.rs @@ -273,6 +273,9 @@ impl Project { write_file(&self.dest_dir.join("index.html"), content)?; write_index = true; } + + // cleanup cache + comemo::evict(5); } }