Cargo Features

Moka has no features set by default.

[dependencies]
moka = { version = "0.12.10", features = ["sync", "future", "logging", "quanta", "atomic64", "unstable-debug-counters"] }
sync

Enable this feature to use moka::sync::{Cache, SegmentedCache}

Affects sync_base::PredicateId, moka::notification, moka::ops, moka::policy

future unstable-debug-counters? = async-lock, event-listener, futures-util

Enable this feature to use moka::future::Cache.

Affects moka::notification, moka::ops, moka::policy

logging = log

Enable this feature to activate optional logging from caches.
Currently cache will emit log only when it encounters a panic in user provided callback closure.

quanta

Enable this feature to use quanta::Instant for some performance critical operations in the cache instead of std::time::Instant. As of v0.12.10, this feature will not make any noticeable performance difference, but in the future when cache metrics are added, it will be useful to have this feature enabled.

Enables quanta

Optional dependencies (enabled by default)

atomic64

This is an old feature and has no effect in v0.12.10 or newer. It is kept for backward compatibility and will be removed in v0.13.0.

unstable-debug-counters = future, once_cell

This unstable feature adds GlobalDebugCounters::current function, which returns counters of internal object construction and destruction. It will have some performance impacts and is intended for debugging.

Features from optional dependencies

In crates that don't use the dep: syntax, optional dependencies automatically become Cargo features. These features may have been created by mistake, and this functionality may be removed in the future.

async-lock future?

Enables async-lock

Optional dependencies (future)

event-listener future?
futures-util future?
log logging?

Enables log

Optional dependencies (logging)

once_cell unstable-debug-counters?

Enables once_cell

Optional dependencies (unstable-debug-counters)