pub struct DefaultPreloader { /* private fields */ }Expand description
Default CachePreloader with a small set of hardcoded heuristics over
the existing top-level cache keys.
Holds a [Weak] reference to the cache to avoid the obvious
Arc<ThingsCache> ↔ Arc<dyn CachePreloader> reference cycle. Once the
last strong reference to the cache is dropped, CachePreloader::warm
becomes a no-op.
Heuristics:
- Accessing
inbox:allpredictstoday:all(priority 8). - Accessing
today:allpredictsinbox:all(priority 10). - Accessing
areas:allpredictsprojects:all(priority 7).
Other keys produce no predictions. Future preloaders (per-project tasks, search-history-driven) plug in via the same trait.
§Warm-loop behaviour
The inbox:all ↔ today:all pair is mutually predictive, which would
ordinarily create a perpetual warming loop. ThingsCache::notify_preloader
guards against this: a predicted key is only enqueued when it is not
already present in the cache. Once both keys are warm, no further
enqueuing occurs until one of them expires or is invalidated.
Implementations§
Source§impl DefaultPreloader
impl DefaultPreloader
Sourcepub fn new(cache: &Arc<ThingsCache>, db: Arc<ThingsDatabase>) -> Arc<Self>
pub fn new(cache: &Arc<ThingsCache>, db: Arc<ThingsDatabase>) -> Arc<Self>
Construct a preloader that holds a [Weak] handle to cache and a
strong handle to db. Wrap in Arc before registering with
ThingsCache::set_preloader.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DefaultPreloader
impl !RefUnwindSafe for DefaultPreloader
impl Send for DefaultPreloader
impl Sync for DefaultPreloader
impl Unpin for DefaultPreloader
impl UnsafeUnpin for DefaultPreloader
impl !UnwindSafe for DefaultPreloader
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
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 more