diff --git a/Cargo.toml b/Cargo.toml index a7d4a78..529c35b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "stretto" -version = "0.4.4" +version = "0.4.6" authors = ["Al Liu "] description = "Stretto is a high performance thread-safe memory-bound Rust cache." homepage = "https://github.com/al8n/stretto" @@ -47,14 +47,14 @@ parking_lot = "0.12" rand = "0.8" serde = {version = "1", optional = true} serde_json = {version = "1", optional = true} -tokio = { version = "1.17", optional = true } +tokio = { version = "1.19", optional = true } twox-hash = "1.6" wg = "0.2" [dev-dependencies] serde = {version = "1", features = ["serde_derive"]} serde_json = "1" -tokio = {version = "1.17", features = ["rt-multi-thread", "test-util"]} +tokio = {version = "1.19", features = ["rt-multi-thread", "test-util"]} [package.metadata.docs.rs] all-features = true diff --git a/src/cache/axync.rs b/src/cache/axync.rs index 20e3948..cf0977c 100644 --- a/src/cache/axync.rs +++ b/src/cache/axync.rs @@ -390,7 +390,7 @@ impl AsyncCache C: Coster, U: UpdateValidator, CB: CacheCallback, - S: BuildHasher + Clone + 'static, + S: BuildHasher + Clone + 'static + Send, { /// `insert` attempts to add the key-value item to the cache. If it returns false, /// then the `insert` was dropped and the key-value item isn't added to the cache. If diff --git a/src/cache/test.rs b/src/cache/test.rs index c4cbba3..849a246 100644 --- a/src/cache/test.rs +++ b/src/cache/test.rs @@ -696,15 +696,14 @@ mod sync_test { fn test_valueref_ttl() { let ttl = Duration::from_secs(1); let c = Cache::builder(100, 1000) - .set_key_builder(TransparentKeyBuilder::default()) - .set_metrics(true) - .finalize() - .unwrap(); + .set_key_builder(TransparentKeyBuilder::default()) + .set_metrics(true) + .finalize() + .unwrap(); c.try_insert_with_ttl(1, 1, 1, ttl).unwrap(); c.wait().unwrap(); let val = c.get(&1).unwrap(); - assert!(val.ttl()>Duration::from_millis(900)); - + assert!(val.ttl() > Duration::from_millis(900)); } } diff --git a/src/policy.rs b/src/policy.rs index ff0bc02..1bb8d52 100644 --- a/src/policy.rs +++ b/src/policy.rs @@ -23,8 +23,8 @@ const DEFAULT_SAMPLES: usize = 5; macro_rules! impl_policy { ($policy: ident) => { - use crate::policy::DEFAULT_SAMPLES; use crate::policy::PolicyPair; + use crate::policy::DEFAULT_SAMPLES; impl $policy { #[inline] diff --git a/src/policy/axync.rs b/src/policy/axync.rs index 057ba86..58f430d 100644 --- a/src/policy/axync.rs +++ b/src/policy/axync.rs @@ -15,7 +15,7 @@ pub(crate) struct AsyncLFUPolicy { pub(crate) metrics: Arc, } -impl AsyncLFUPolicy { +impl AsyncLFUPolicy { #[inline] pub fn with_hasher(ctrs: usize, max_cost: i64, hasher: S) -> Result { let inner = PolicyInner::with_hasher(ctrs, max_cost, hasher)?; @@ -84,7 +84,7 @@ pub(crate) struct PolicyProcessor { stop_rx: Receiver<()>, } -impl PolicyProcessor { +impl PolicyProcessor { #[inline] fn new( inner: Arc>>, @@ -130,8 +130,8 @@ impl PolicyProcessor { } -unsafe impl Send for PolicyProcessor {} -unsafe impl Sync for PolicyProcessor {} +unsafe impl Send for PolicyProcessor {} +unsafe impl Sync for PolicyProcessor {} impl_policy!(AsyncLFUPolicy); \ No newline at end of file