pub struct CacheConfig { /* private fields */ }Expand description
Settings for the client cache, given once to use_client_cache.
use g3_cache::CacheConfig;
use std::time::Duration;
let config = CacheConfig::new("media-mancer").keep_for(Duration::from_secs(3 * 24 * 60 * 60));Implementations§
Source§impl CacheConfig
impl CacheConfig
Sourcepub fn new(name: impl Into<Cow<'static, str>>) -> Self
pub fn new(name: impl Into<Cow<'static, str>>) -> Self
Settings with the defaults below. name names the persistent store
(the IndexedDB database, or the redb file on mobile), so it must be
unique to the app on a device or origin.
Sourcepub fn max_entries(self, count: usize) -> Self
pub fn max_entries(self, count: usize) -> Self
Maximum answers in each store. Default 256; zero disables storage.
Sourcepub fn max_bytes(self, bytes: usize) -> Self
pub fn max_bytes(self, bytes: usize) -> Self
Maximum combined JSON payload bytes in each store. Default 32 MiB. This estimates payload size, not the allocator or database overhead.
How recent a fetch a screen may reuse instead of repeating it when it
opens. Default 2 s. This only merges the reads of components that
mount together (a screen and its children reading the same thing);
keep it short, since a change made without invalidate_cached shows only
once something refetches.
Sourcepub fn keep_for(self, duration: Duration) -> Self
pub fn keep_for(self, duration: Duration) -> Self
How old a stored value may be and still be shown on a cold start while its refetch runs. Default 7 days: an older list is more misleading than a loading state.
Sourcepub fn revalidate_on_focus(self, on: bool) -> Self
pub fn revalidate_on_focus(self, on: bool) -> Self
Whether returning to the app (the tab or window regaining focus, the app coming back to the foreground, the network coming back) refetches every mounted read. Default on. This is what shows changes made on another device on a screen that stayed open; see the crate docs.