pub struct GlwEventCache { /* private fields */ }Expand description
Three-tier cache for GLW events.
&mut self is required on the read methods because the in-memory
LRU promotes entries on access and the redb writes happen on the
write path.
Implementations§
Source§impl GlwEventCache
impl GlwEventCache
Sourcepub fn new(
cache_directory: PathBuf,
base_url: Option<Url>,
) -> Result<Self, GlwEventCacheError>
pub fn new( cache_directory: PathBuf, base_url: Option<Url>, ) -> Result<Self, GlwEventCacheError>
Create a new cache backed by <cache_directory>/glw_event.redb.
base_url is the GLW base URL (must include the version segment
as a path, e.g. http://example.com/glw127/). Pass None to use
the workspace default.
§Errors
Returns GlwEventCacheError if the database file cannot be
created or if the default URL fails to parse (the latter being
unreachable for the hard-coded defaults).
Sourcepub async fn get_event_by_id(
&mut self,
id: EventId,
) -> Result<Option<GlwEvent>, GlwEventCacheError>
pub async fn get_event_by_id( &mut self, id: EventId, ) -> Result<Option<GlwEvent>, GlwEventCacheError>
Get a GLW event by numeric id.
Returns Ok(None) if the server reports no such event.
§Errors
Returns GlwEventCacheError if a database or upstream HTTP
operation fails.
Sourcepub async fn get_event_by_key(
&mut self,
key: &GlwEventKey,
) -> Result<Option<GlwEvent>, GlwEventCacheError>
pub async fn get_event_by_key( &mut self, key: &GlwEventKey, ) -> Result<Option<GlwEvent>, GlwEventCacheError>
Get a GLW event by string event key.
§Errors
Returns GlwEventCacheError if a database or upstream HTTP
operation fails.
Sourcepub async fn refresh_event_by_id(
&mut self,
id: EventId,
) -> Result<Option<GlwEvent>, GlwEventCacheError>
pub async fn refresh_event_by_id( &mut self, id: EventId, ) -> Result<Option<GlwEvent>, GlwEventCacheError>
Force a fresh fetch of an event by id, bypassing all cache tiers.
§Errors
Returns GlwEventCacheError if a database or upstream HTTP
operation fails.
Sourcepub async fn refresh_event_by_key(
&mut self,
key: &GlwEventKey,
) -> Result<Option<GlwEvent>, GlwEventCacheError>
pub async fn refresh_event_by_key( &mut self, key: &GlwEventKey, ) -> Result<Option<GlwEvent>, GlwEventCacheError>
Force a fresh fetch of an event by key, bypassing all cache tiers.
§Errors
Returns GlwEventCacheError if a database or upstream HTTP
operation fails.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for GlwEventCache
impl !UnwindSafe for GlwEventCache
impl Freeze for GlwEventCache
impl Send for GlwEventCache
impl Sync for GlwEventCache
impl Unpin for GlwEventCache
impl UnsafeUnpin for GlwEventCache
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.