Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_or_insert_with method #20

Merged
merged 12 commits into from
Jul 8, 2021
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Moka — Change Log

## Version 0.5.0 (Not released yet)

### Added

- Add `get_or_insert_with` and `get_or_try_insert_with` methods to `sync` and
`future` caches. ([#20][gh-pull-0020])


## Version 0.4.0

### Fixed
Expand All @@ -15,6 +23,7 @@
- Add `invalidate_entries_if` method to `sync`, `future` and `unsync` caches.
([#12][gh-pull-0012])


## Version 0.3.1

### Changed
Expand Down Expand Up @@ -65,6 +74,7 @@

[caffeine-git]: https://github.com/ben-manes/caffeine

[gh-pull-0020]: https://github.com/moka-rs/moka/pull/20/
[gh-pull-0019]: https://github.com/moka-rs/moka/pull/19/
[gh-pull-0016]: https://github.com/moka-rs/moka/pull/16/
[gh-pull-0012]: https://github.com/moka-rs/moka/pull/12/
Expand Down
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "moka"
version = "0.4.0"
version = "0.5.0"
authors = ["Tatsuya Kawano <tatsuya@hibaridb.org>"]
edition = "2018"

Expand All @@ -21,7 +21,7 @@ features = ["future"]

[features]
default = []
future = ["async-io"]
future = ["async-io", "async-lock"]

[dependencies]
cht = "0.4"
Expand All @@ -35,7 +35,8 @@ thiserror = "1.0"
uuid = { version = "0.8", features = ["v4"] }

# Optional dependencies
async-io = { version = "1", optional = true }
async-io = { version = "1.4", optional = true }
async-lock = { version = "2.4", optional = true }

[dev-dependencies]
actix-rt2 = { package = "actix-rt", version = "2", default-features = false }
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ Add this to your `Cargo.toml`:

```toml
[dependencies]
moka = "0.4"
moka = "0.5"
```

To use the asynchronous cache, enable a crate feature called "future".

```toml
[dependencies]
moka = { version = "0.4", features = ["future"] }
moka = { version = "0.5", features = ["future"] }
```


Expand Down Expand Up @@ -164,7 +164,7 @@ Here is a similar program to the previous example, but using asynchronous cache
// Cargo.toml
//
// [dependencies]
// moka = { version = "0.4", features = ["future"] }
// moka = { version = "0.5", features = ["future"] }
// tokio = { version = "1", features = ["rt-multi-thread", "macros" ] }
// futures = "0.3"

Expand Down
1 change: 1 addition & 0 deletions src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

mod builder;
mod cache;
mod value_initializer;

pub use builder::CacheBuilder;
pub use cache::Cache;
Expand Down
Loading