Repository: jaemk/cached (language: rust)

Issue:
Tokio included when not using async
Hello, 
when including cached (`cached = { version = "*", default-features = false, features = [
    "proc_macro",
] }`)

tokio is also built, is there a reason that tokio is included when async is disabled?
Also how come async is part of the default features?, I would suspect a large portion of people do not use the async features and it would be better to not have it as part of the default features?, reducing compile time, and bin size.


Discussion / hints:
The reason seem to be because we use `tokio` primatives instead of `std` even when `async` is not enabled? Is there a performance reason this is the case or compatibility? 

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 799ccbb..15edf40 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,14 +2,12 @@
 
 ## [Unreleased]
 ## Added
+- Generate `*_no_cache` function for every cached function to allow calling the original function
+  without caching. This is backwards incompatible if you have a function with the same name.
 ## Changed
-## Removed
-
-## [Unreleased]
-## Added
-- Also generate `*_origin` function for every cached function to allow calling the original function
-  without caching. It can be backward incompatible, if you have a function with the same name.
-## Changed
+- `tokio` dependency has been removed from `proc_macro` feature (originally unecessarily included).
+- `async` feature has been removed from the `default` feature. This is a backwards incompatible change.
+  If you want to use `async` features, you need to enable `async` explicitly.
 ## Removed
 
 ## [0.44.0] / [cached_proc_macro[0.17.0]]
diff --git a/Cargo.toml b/Cargo.toml
index c522948..ec3f49c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,8 +16,8 @@ all-features = true
 rustdoc-args = ["--cfg", "docsrs"]
 
 [features]
-default = ["proc_macro", "async"]
-proc_macro = ["tokio", "cached_proc_macro", "cached_proc_macro_types"]
+default = ["proc_macro"]
+proc_macro = ["cached_proc_macro", "cached_proc_macro_types"]
 async = ["futures", "tokio", "async-trait"]
 async_tokio_rt_multi_thread = ["async", "tokio/rt-multi-thread"]
 redis_store = ["redis", "r2d2", "serde", "serde_json"]
@@ -99,3 +99,15 @@ members = ["cached_proc_macro","examples/wasm"]
 [[example]]
 name = "redis"
 required-features = ["redis_store", "proc_macro"]
+
+[[example]]
+name = "redis-async"
+required-features = ["async", "proc_macro"]
+
+[[example]]
+name = "tokio"
+required-features = ["async", "proc_macro"]
+
+[[example]]
+name = "async_std"
+required-features = ["async", "proc_macro"]
diff --git a/examples/wasm/Cargo.toml b/examples/wasm/Cargo.toml
index 46f6f84..ffc5552 100644
--- a/examples/wasm/Cargo.toml
+++ b/examples/wasm/Cargo.toml
@@ -9,7 +9,7 @@ publish = false
 [dependencies.cached]
 path ="../.."
 default_features = false
-features = ["proc_macro", "wasm"]
+features = ["proc_macro", "wasm", "async"]
 
 [dependencies.chrono]
 version = "0.4"
diff --git a/src/lib.rs b/src/lib.rs
index 41fdd08..2d597a6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -201,7 +201,7 @@ pub mod stores;
 #[doc(hidden)]
 pub use instant;
 
-#[cfg(any(feature = "proc_macro", feature = "async"))]
+#[cfg(feature = "async")]
 #[doc(hidden)]
 pub mod async_sync {
     pub use tokio::sync::Mutex;


Test patch: