Type Alias governor::state::keyed::HashMapStateStore

source ·
pub type HashMapStateStore<K> = Mutex<HashMap<K, InMemoryState>>;
Expand description

A thread-safe (but not very performant) implementation of a keyed rate limiter state store using HashMap.

The HashMapStateStore is the default state store in std when no other thread-safe features are enabled.

Aliased Type§

struct HashMapStateStore<K> { /* private fields */ }

Trait Implementations§

source§

impl<K: Hash + Eq + Clone> ShrinkableKeyedStateStore<K> for HashMapStateStore<K>

source§

fn retain_recent(&self, drop_below: Nanos)

Remove those keys with state older than drop_below.
source§

fn shrink_to_fit(&self)

Shrinks the capacity of the state store, if possible. Read more
source§

fn len(&self) -> usize

Returns the number of “live” keys stored in the state store. Read more
source§

fn is_empty(&self) -> bool

Returns true if self has no keys stored in it. Read more
source§

impl<K: Hash + Eq + Clone> StateStore for HashMapStateStore<K>

§

type Key = K

The type of key that the state store can represent.
source§

fn measure_and_replace<T, F, E>(&self, key: &Self::Key, f: F) -> Result<T, E>
where F: Fn(Option<Nanos>) -> Result<(T, Nanos), E>,

Updates a state store’s rate limiting state for a given key, using the given closure. Read more