Mercurial > lbo > hg > memoize
changeset 39:390b3b7095cc
Set up GH actions
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Thu, 10 Dec 2020 19:20:26 +0100 |
parents | c266d26acf7f |
children | 6c8733dd9730 |
files | .github/workflows/test.yml README.md |
diffstat | 2 files changed, 30 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.github/workflows/test.yml Thu Dec 10 19:20:26 2020 +0100 @@ -0,0 +1,20 @@ +on: [push] + +name: CI + +jobs: + build_and_test: + name: Rust project + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - uses: actions-rs/cargo@v1 + with: + command: test + args: --features full + - uses: actions-rs/cargo@v1 + with: + command: test
--- a/README.md Thu Dec 10 19:17:23 2020 +0100 +++ b/README.md Thu Dec 10 19:20:26 2020 +0100 @@ -2,6 +2,7 @@ [![Docs.rs](https://docs.rs/memoize/badge.svg)](https://docs.rs/memoize) [![Crates.rs](https://img.shields.io/crates/v/memoize.svg)](https://crates.io/crates/memoize) +[![CI](https://github.com/dermesser/rex/workflows/CI/badge.svg)](actions) A `#[memoize]` attribute for somewhat simple Rust functions: That is, functions with one or more `Clone`-able arguments, and a `Clone`-able return type. That's it. @@ -77,17 +78,22 @@ of parsing attribute parameters. Currently, compiling will fail if you use a parameter such as `Capacity` without the feature `full` being enabled. +Another parameter is TimeToLive, specifying how long a cached value is allowed +to live: -Another parameter is TimeToLive - it's targeting to refresh outdated values. -Example: ```rust #[memoize(Capacity: 123, TimeToLive: Duration::from_secs(2))] ``` -chrono::Duration is also possible, but have to be converted into std::time::Duration + +`chrono::Duration` is also possible, but would have to first be converted to +`std::time::Duration` + ```rust #[memoize(TimeToLive: chrono::Duration::hours(3).to_std().unwrap())] ``` -cached value will be actual no longer than duration provided and refreshed with next request. + +The cached value will never be older than duration provided and instead +recalculated on the next request. ## Contributions