Rust

pool

Module

[Pool]: every operation on an adapter borrowed from a utopia_pools::Pool.

Contents

use utopia_cache::Pool;
Rust
pub struct Pool<A, S = Stack<A>>

Runs every operation on an adapter borrowed from a utopia_pools::Pool, returning it afterwards (or discarding it when the operation failed), so concurrent tasks never share one connection.

Rust
use php_std::types::Value;
use utopia_cache::{Adapter, Memory, Pool};

let memories = utopia_pools::Pool::new(
    utopia_pools::Stack::new(),
    "cache",
    4,
    || async { Ok::<_, std::convert::Infallible>(Memory::new()) },
    0.0,
)
.unwrap();
let pool = Pool::new(memories).await?;
assert!(pool.save("key", &Value::from("value"), "", 0).await?);
assert_eq!(pool.name(None), "memory");