From 023a2d8da9419a496fe995338de79162da23c898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Gaillard?= Date: Thu, 3 Nov 2022 02:52:29 +0100 Subject: [PATCH] feat: add a feature flag to enable the cache --- Cargo.toml | 5 ++++- src/client.rs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index adf135a..4b399b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" [dependencies] askama = { version = "0.11.1", default-features = false } async-recursion = "1.0.0" -cached = "0.40.0" +cached = { version = "0.40.0", optional = true } clap = { version = "4.0.18", default-features = false, features = ["std"] } regex = "1.6.0" serde = { version = "1.0.147", features = ["derive"] } @@ -25,3 +25,6 @@ tokio = { version = "1.21.2", features = ["full"] } time = "0.3.16" url = "2.3.1" rust-embed = { version = "6.4.2", features = ["include-exclude"] } + +[features] +default = ["cached"] diff --git a/src/client.rs b/src/client.rs index da271dd..c9c017a 100644 --- a/src/client.rs +++ b/src/client.rs @@ -112,7 +112,7 @@ fn request(url: String, quarantine: bool) -> Boxed, String } // Make a request to a Reddit API and parse the JSON response -#[cached(size = 100, time = 30, result = true)] +#[cfg_attr(feature = "cached", cached(size = 100, time = 30, result = true))] pub async fn json(path: String, quarantine: bool) -> Result { // Build Reddit url from path let url = format!("https://www.reddit.com{}", path);