Trait CachePolicy

Source
pub trait CachePolicy {
    type Transformer: Transformer;
    type CacheId: Ord + Hash + Sized + Clone + Send + Sync + Debug + 'static;
    type CacheLoader: CacheLoader<Self::Transformer>;

    const QUERY_DATABASE: bool;
    const QUERY_DATABASE_IF_NOT_FULL: bool;
    const LOAD_DATABASE: bool;
    const LOAD_MOST_RECENT_FIRST: bool;
    const SIZE: usize;
    const MAX_SIZE: usize;
}
Expand description

Defines how caching of entities and events is handled

Required Associated Constants§

Source

const QUERY_DATABASE: bool

Indicates whether the database should be queried on a cache miss

Source

const QUERY_DATABASE_IF_NOT_FULL: bool

Indicates whether the database should be queried on a cache miss if the size of the cache is less than SIZE Only has an effect if QUERY_DATABASE is true

Source

const LOAD_DATABASE: bool

Indicates whether the database should be queried to load the cache initially

Source

const LOAD_MOST_RECENT_FIRST: bool

Whether or not to load most recent values from the database first

Source

const SIZE: usize

When the cache surpasses SIZE it will be reduced back down to SIZE setting this to 0 clears it out after each block group. Defaults to 5000.

Source

const MAX_SIZE: usize

When the cache surpasses MAX_SIZE it will be reduced back down to SIZE setting this to 0 makes it so that nothing is ever cached. Defaults to SIZE + max(SIZE, 100) / 10; if SIZE is default that would be 5_500.

Required Associated Types§

Source

type Transformer: Transformer

Related Transformer

Source

type CacheId: Ord + Hash + Sized + Clone + Send + Sync + Debug + 'static

The type of key used when looking up the cache. This will be the same as the id field if using a default policy

Source

type CacheLoader: CacheLoader<Self::Transformer>

Struct to use for loading the cache. This could have a custom implementation to only load the rows required from the database

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§