Skip to main content

moka

5 configuration options · available in Rust, Python, Node.js, Java

Quick start
use opendal::Operator;

let op = Operator::via_iter("moka", [
])?;
All configuration options (copy & trim)
Full reference
use opendal::Operator;

let op = Operator::via_iter("moka", [
// Name for this cache instance.
// ("name".to_string(), "...".to_string()),

// Sets the max capacity of the cache.
//
// Refer to [`moka::future::CacheBuilder::max_capacity`](https://docs.rs/moka/latest/moka/future/struct.CacheBuilder.html#method.max_capacity)
// ("max_capacity".to_string(), "1000".to_string()),

// Sets the time to live of the cache.
//
// Refer to [`moka::future::CacheBuilder::time_to_live`](https://docs.rs/moka/latest/moka/future/struct.CacheBuilder.html#method.time_to_live)
// ("time_to_live".to_string(), "...".to_string()),

// Sets the time to idle of the cache.
//
// Refer to [`moka::future::CacheBuilder::time_to_idle`](https://docs.rs/moka/latest/moka/future/struct.CacheBuilder.html#method.time_to_idle)
// ("time_to_idle".to_string(), "...".to_string()),

// root path of this backend
// ("root".to_string(), "...".to_string()),

])?;

Every option is passed as a string key; OpenDAL parses it into the right type. Some services may require building the binding with the matching services-* feature enabled.

Configuration reference

General5
KeyTypeRequiredDescription
namestringnoName for this cache instance.
max_capacityintegernoSets the max capacity of the cache. Refer to [moka::future::CacheBuilder::max_capacity](https://docs.rs/moka/latest/moka/future/struct.CacheBuilder.html#method.max_capacity)
time_to_livestringnoSets the time to live of the cache. Refer to [moka::future::CacheBuilder::time_to_live](https://docs.rs/moka/latest/moka/future/struct.CacheBuilder.html#method.time_to_live)
time_to_idlestringnoSets the time to idle of the cache. Refer to [moka::future::CacheBuilder::time_to_idle](https://docs.rs/moka/latest/moka/future/struct.CacheBuilder.html#method.time_to_idle)
rootstringnoroot path of this backend