From 9d391626dc06aa2ae47c52b9c92056f7b5878bbb Mon Sep 17 00:00:00 2001 From: Tatsuya Kawano Date: Sat, 19 Mar 2022 18:21:24 +0800 Subject: [PATCH] Prepare for v0.8.0 release - Bump the version to v0.8.0. - Remove actix-rt v1.x from the dev dependencies. --- CHANGELOG.md | 3 ++ Cargo.toml | 5 ++- README.md | 10 +++--- src/future/builder.rs | 2 +- src/future/cache.rs | 10 +++--- tests/runtime_actix_rt1.rs | 68 -------------------------------------- tests/runtime_actix_rt2.rs | 2 +- 7 files changed, 17 insertions(+), 83 deletions(-) delete mode 100644 tests/runtime_actix_rt1.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index b024befe..962ed322 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Moka — Change Log +## Version 0.8.0 + + ## Version 0.7.2 The minimum supported Rust version (MSRV) is now 1.51.0 (2021-03-25). diff --git a/Cargo.toml b/Cargo.toml index 304d05b8..5c6826da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "moka" -version = "0.7.2" +version = "0.8.0" edition = "2018" rust-version = "1.51" @@ -53,8 +53,7 @@ async-lock = { version = "2.4", optional = true } futures-util = { version = "0.3", optional = true } [dev-dependencies] -actix-rt2 = { package = "actix-rt", version = "2", default-features = false } -actix-rt1 = { package = "actix-rt", version = "1", default-features = false } +actix-rt = { version = "2", default-features = false } async-std = { version = "1", default-features = false, features = ["attributes"] } getrandom = "0.2" reqwest = "0.11" diff --git a/README.md b/README.md index aba61ce0..bbdfaf18 100644 --- a/README.md +++ b/README.md @@ -84,14 +84,14 @@ Add this to your `Cargo.toml`: ```toml [dependencies] -moka = "0.7" +moka = "0.8" ``` To use the asynchronous cache, enable a crate feature called "future". ```toml [dependencies] -moka = { version = "0.7", features = ["future"] } +moka = { version = "0.8", features = ["future"] } ``` @@ -193,7 +193,7 @@ Here is a similar program to the previous example, but using asynchronous cache // Cargo.toml // // [dependencies] -// moka = { version = "0.7", features = ["future"] } +// moka = { version = "0.8", features = ["future"] } // tokio = { version = "1", features = ["rt-multi-thread", "macros" ] } // futures-util = "0.3" @@ -435,9 +435,9 @@ to the dependency declaration. ```toml:Cargo.toml [dependencies] -moka = { version = "0.7", default-feautures = false } +moka = { version = "0.8", default-feautures = false } # Or -moka = { version = "0.7", default-feautures = false, features = ["future"] } +moka = { version = "0.8", default-feautures = false, features = ["future"] } ``` This will make Moka to switch to a fall-back implementation, so it will compile. diff --git a/src/future/builder.rs b/src/future/builder.rs index d9387f75..d9262e83 100644 --- a/src/future/builder.rs +++ b/src/future/builder.rs @@ -19,7 +19,7 @@ use std::{ /// // Cargo.toml /// // /// // [dependencies] -/// // moka = { version = "0.7", features = ["future"] } +/// // moka = { version = "0.8", features = ["future"] } /// // tokio = { version = "1", features = ["rt-multi-thread", "macros" ] } /// // futures = "0.3" /// diff --git a/src/future/cache.rs b/src/future/cache.rs index efdf53e4..8593bd32 100644 --- a/src/future/cache.rs +++ b/src/future/cache.rs @@ -59,7 +59,7 @@ use std::{ /// // Cargo.toml /// // /// // [dependencies] -/// // moka = { version = "0.7", features = ["future"] } +/// // moka = { version = "0.8", features = ["future"] } /// // tokio = { version = "1", features = ["rt-multi-thread", "macros" ] } /// // futures-util = "0.3" /// @@ -144,7 +144,7 @@ use std::{ /// // Cargo.toml /// // /// // [dependencies] -/// // moka = { version = "0.7", features = ["future"] } +/// // moka = { version = "0.8", features = ["future"] } /// // tokio = { version = "1", features = ["rt-multi-thread", "macros" ] } /// // futures-util = "0.3" /// @@ -206,7 +206,7 @@ use std::{ /// // Cargo.toml /// // /// // [dependencies] -/// // moka = { version = "0.7", features = ["future"] } +/// // moka = { version = "0.8", features = ["future"] } /// // tokio = { version = "1", features = ["rt-multi-thread", "macros" ] } /// // futures-util = "0.3" /// @@ -394,7 +394,7 @@ where /// // Cargo.toml /// // /// // [dependencies] - /// // moka = { version = "0.7", features = ["future"] } + /// // moka = { version = "0.8", features = ["future"] } /// // futures-util = "0.3" /// // tokio = { version = "1", features = ["rt-multi-thread", "macros" ] } /// use moka::future::Cache; @@ -485,7 +485,7 @@ where /// // Cargo.toml /// // /// // [dependencies] - /// // moka = { version = "0.7", features = ["future"] } + /// // moka = { version = "0.8", features = ["future"] } /// // futures-util = "0.3" /// // reqwest = "0.11" /// // tokio = { version = "1", features = ["rt-multi-thread", "macros" ] } diff --git a/tests/runtime_actix_rt1.rs b/tests/runtime_actix_rt1.rs deleted file mode 100644 index 9c3bb1f7..00000000 --- a/tests/runtime_actix_rt1.rs +++ /dev/null @@ -1,68 +0,0 @@ -#![cfg(features = "future")] - -use actix_rt1::{Arbiter, System}; -use moka::future::Cache; - -fn main() { - const NUM_TASKS: usize = 16; - const NUM_KEYS_PER_TASK: usize = 64; - - fn value(n: usize) -> String { - format!("value {}", n) - } - - // Create a cache that can store up to 10,000 entries. - let cache = Cache::new(10_000); - - // Create Actix Runtime - let _ = System::new(); - let arbiter = Arbiter::new(); - - // Spawn async tasks and write to and read from the cache. - let tasks: Vec<_> = (0..NUM_TASKS) - .map(|i| { - // To share the same cache across the async tasks, clone it. - // This is a cheap operation. - let my_cache = cache.clone(); - let start = i * NUM_KEYS_PER_TASK; - let end = (i + 1) * NUM_KEYS_PER_TASK; - - // NOTE: Actix Runtime is single threaded. - arbiter.spawn(async move { - // Insert 64 entries. (NUM_KEYS_PER_TASK = 64) - for key in start..end { - if key % 8 == 0 { - my_cache.blocking_insert(key, value(key)); - } else { - // insert() is an async method, so await it - my_cache.insert(key, value(key)).await; - } - // get() returns Option, a clone of the stored value. - assert_eq!(my_cache.get(&key), Some(value(key))); - } - - // Invalidate every 4 element of the inserted entries. - for key in (start..end).step_by(4) { - if key % 8 == 0 { - my_cache.blocking_invalidate(&key).await; - } else { - // invalidate() is an async method, so await it - my_cache.invalidate(&key).await; - } - } - }) - }) - .collect(); - - // Wait for all tasks to complete. - futures_util::future::join_all(tasks).await; - - // Verify the result. - for key in 0..(NUM_TASKS * NUM_KEYS_PER_TASK) { - if key % 4 == 0 { - assert_eq!(cache.get(&key), None); - } else { - assert_eq!(cache.get(&key), Some(value(key))); - } - } -} diff --git a/tests/runtime_actix_rt2.rs b/tests/runtime_actix_rt2.rs index 3696aeee..a3149aa2 100644 --- a/tests/runtime_actix_rt2.rs +++ b/tests/runtime_actix_rt2.rs @@ -1,6 +1,6 @@ #![cfg(features = "future")] -use actix_rt2::{Arbiter, System}; +use actix_rt::{Arbiter, System}; use moka::future::Cache; fn main() {