pub struct RedisEvictionManager { /* private fields */ }Expand description
Proactive Redis eviction manager.
Reuses TanCurvePolicy from the memory eviction module for consistent
scoring across L1 (memory) and L2 (Redis) caches.
Implementations§
Source§impl RedisEvictionManager
impl RedisEvictionManager
Sourcepub fn new(config: RedisEvictionConfig, prefix: Option<String>) -> Self
pub fn new(config: RedisEvictionConfig, prefix: Option<String>) -> Self
Create a new eviction manager.
Sourcepub fn needs_profile_refresh(&self) -> bool
pub fn needs_profile_refresh(&self) -> bool
Check if we need to refresh the memory profile.
Sourcepub fn refresh_profile(&self, used_bytes: u64, max_bytes: u64)
pub fn refresh_profile(&self, used_bytes: u64, max_bytes: u64)
Update memory profile from Redis INFO output.
Sourcepub fn record_batch_write(&self, bytes: u64)
pub fn record_batch_write(&self, bytes: u64)
Record a batch write (updates pending estimate).
Sourcepub fn record_key_write(&self, key: &str, size_bytes: usize)
pub fn record_key_write(&self, key: &str, size_bytes: usize)
Record a key write (for eviction scoring).
Sourcepub fn record_key_access(&self, key: &str)
pub fn record_key_access(&self, key: &str)
Record a key access (touch for LRU scoring).
Sourcepub fn remove_key(&self, key: &str)
pub fn remove_key(&self, key: &str)
Remove key from tracking (after eviction or deletion).
Sourcepub fn needs_eviction(&self) -> bool
pub fn needs_eviction(&self) -> bool
Check if eviction is needed.
Sourcepub fn get_eviction_candidates(&self) -> Vec<String>
pub fn get_eviction_candidates(&self) -> Vec<String>
Get keys to evict, sorted by eviction score (lowest first).
Returns up to eviction_batch_size keys.
Sourcepub fn stats(&self) -> RedisEvictionStats
pub fn stats(&self) -> RedisEvictionStats
Get statistics for monitoring.
Auto Trait Implementations§
impl Freeze for RedisEvictionManager
impl !RefUnwindSafe for RedisEvictionManager
impl Send for RedisEvictionManager
impl Sync for RedisEvictionManager
impl Unpin for RedisEvictionManager
impl !UnwindSafe for RedisEvictionManager
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