pub struct CacheSession {
pub matched_prefix_len: usize,
pub block_indices: Vec<usize>,
}Expand description
A handle that tracks which cache blocks a specific request is using.
Holding a CacheSession keeps the referenced blocks’ ref_count
elevated so they will not be evicted while the request is in flight.
Fields§
§matched_prefix_len: usizeNumber of prefix tokens that were already cached.
block_indices: Vec<usize>Indices of the cache blocks matched for this session (in order).
Implementations§
Source§impl CacheSession
impl CacheSession
Sourcepub fn new(matched_prefix_len: usize, block_indices: Vec<usize>) -> Self
pub fn new(matched_prefix_len: usize, block_indices: Vec<usize>) -> Self
Create a new session handle.
Sourcepub fn cached_tokens(&self, block_size: usize) -> usize
pub fn cached_tokens(&self, block_size: usize) -> usize
Number of tokens covered by cached blocks in this session.
May differ slightly from matched_prefix_len if the prefix was not
an exact multiple of block_size, but in practice they will be equal.
Auto Trait Implementations§
impl Freeze for CacheSession
impl RefUnwindSafe for CacheSession
impl Send for CacheSession
impl Sync for CacheSession
impl Unpin for CacheSession
impl UnsafeUnpin for CacheSession
impl UnwindSafe for CacheSession
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
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>
Converts
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>
Converts
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