Skip to main content

ObjectCache

Trait ObjectCache 

Source
pub trait ObjectCache<K, V>: Send + Sync {
    // Required methods
    fn get(&self, key: &K) -> Option<V>;
    fn set(&self, key: K, value: V);
}
Expand description

A trait for caching in-memory objects of given type.

§Notes

ObjectCache will store deeply nested objects, such as Manifest, which contains Schema. Please ensure that the cache stores the object in memory as-is, without attempting to serialize it, as serialization could be extremely expensive.

Required Methods§

Source

fn get(&self, key: &K) -> Option<V>

Gets an object from the cache by its key.

Source

fn set(&self, key: K, value: V)

Sets an object in the cache with the given key and value.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§