pub struct ResultCache { /* private fields */ }Expand description
LRU cache of engine answers, keyed by the prose that produced them.
A keystroke re-checks the whole document: the prose is re-extracted and
every range goes back to the engines, though only the edited one changed.
For LanguageTool that is the difference between one small request and a
hundred — measured on a 36 kB Typst file against a 4-CPU server, 838 ms per
keystroke pause against 108 ms.
Answers are cached as the engine returned them: offsets relative to the range, rule ids not yet normalised. Normalisation and the severity overrides run over cached answers as over fresh ones, so changing a rule’s severity takes effect without waiting for the cache to turn over.
Implementations§
Source§impl ResultCache
impl ResultCache
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
A cache holding capacity answers, or a disabled one when that is zero.
A disabled cache misses every lookup and stores nothing.
Sourcepub fn get(
&mut self,
engine: &'static str,
language: &str,
text: &str,
) -> Option<Vec<Diagnostic>>
pub fn get( &mut self, engine: &'static str, language: &str, text: &str, ) -> Option<Vec<Diagnostic>>
The engine’s last answer for this prose, if it is still held.
Sourcepub fn put(
&mut self,
engine: &'static str,
language: &str,
text: &str,
diagnostics: Vec<Diagnostic>,
)
pub fn put( &mut self, engine: &'static str, language: &str, text: &str, diagnostics: Vec<Diagnostic>, )
Remember what the engine answered for this prose.
pub fn is_empty(&self) -> bool
Auto Trait Implementations§
impl Freeze for ResultCache
impl RefUnwindSafe for ResultCache
impl Send for ResultCache
impl Sync for ResultCache
impl Unpin for ResultCache
impl UnsafeUnpin for ResultCache
impl UnwindSafe for ResultCache
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> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
self file descriptor. Read moreSource§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