pub struct SettingsCache {
repo: Arc<dyn SettingsRepository>,
snapshot: RwLock<Option<(Arc<Settings>, Instant)>>,
ttl: Duration,
}Expand description
A settings snapshot refreshed at most once per TTL window.
Fields§
§repo: Arc<dyn SettingsRepository>§snapshot: RwLock<Option<(Arc<Settings>, Instant)>>The current snapshot and the instant it expires. None until the first
successful load.
ttl: DurationImplementations§
Source§impl SettingsCache
impl SettingsCache
Sourcepub fn new(repo: Arc<dyn SettingsRepository>) -> Self
pub fn new(repo: Arc<dyn SettingsRepository>) -> Self
Wrap a repository with the default TTL.
Sourcepub fn with_ttl(repo: Arc<dyn SettingsRepository>, ttl: Duration) -> Self
pub fn with_ttl(repo: Arc<dyn SettingsRepository>, ttl: Duration) -> Self
Wrap a repository with an explicit TTL.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SettingsCache
impl !RefUnwindSafe for SettingsCache
impl Send for SettingsCache
impl Sync for SettingsCache
impl Unpin for SettingsCache
impl UnsafeUnpin for SettingsCache
impl !UnwindSafe for SettingsCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more