pub struct RowCache { /* private fields */ }Expand description
Bounded LRU row cache: stores the last max materialized rows, keyed by
row index, to avoid re-fetching identical rows from a RowSource.
The eviction policy is LRU-approximate: the oldest-inserted entry is evicted when the cache is full. Entries are also bumped to the back of the deque on re-insertion (cache-hit update).
Implementations§
Source§impl RowCache
impl RowCache
Sourcepub fn new(max: usize) -> Self
pub fn new(max: usize) -> Self
Create a new cache that holds at most max rows.
Setting max to 0 effectively disables caching (every lookup misses).
Sourcepub fn get(&self, index: usize) -> Option<&Vec<Cell>>
pub fn get(&self, index: usize) -> Option<&Vec<Cell>>
Look up a row by index. Returns None on a cache miss.
Sourcepub fn insert(&mut self, index: usize, cells: Vec<Cell>)
pub fn insert(&mut self, index: usize, cells: Vec<Cell>)
Insert or update a row in the cache.
If an entry for index already exists it is removed first so the
refreshed entry goes to the back (most-recently-used position). When
the cache is at capacity the front (least-recently-used) entry is
evicted before insertion.
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Invalidate the entire cache. Call when the underlying RowSource changes.
Auto Trait Implementations§
impl !RefUnwindSafe for RowCache
impl !Sync for RowCache
impl !UnwindSafe for RowCache
impl Freeze for RowCache
impl Send for RowCache
impl Unpin for RowCache
impl UnsafeUnpin for RowCache
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> 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