pub struct TTLManager { /* private fields */ }
Expand description
TTL manager for tracking and cleaning up expired keys
Implementations§
Source§impl TTLManager
impl TTLManager
Sourcepub fn new(config: TTLConfig) -> TTLManager
pub fn new(config: TTLConfig) -> TTLManager
Create a new TTL manager
Sourcepub async fn set_ttl(
&self,
key: String,
db_id: u8,
ttl_seconds: u64,
) -> Result<(), MapletError>
pub async fn set_ttl( &self, key: String, db_id: u8, ttl_seconds: u64, ) -> Result<(), MapletError>
Set TTL for a key
Sourcepub async fn get_ttl(&self, key: &str) -> Result<Option<i64>, MapletError>
pub async fn get_ttl(&self, key: &str) -> Result<Option<i64>, MapletError>
Get TTL for a key in seconds
Sourcepub async fn remove_ttl(&self, key: &str) -> Result<(), MapletError>
pub async fn remove_ttl(&self, key: &str) -> Result<(), MapletError>
Remove TTL for a key
Sourcepub async fn is_expired(&self, key: &str) -> Result<bool, MapletError>
pub async fn is_expired(&self, key: &str) -> Result<bool, MapletError>
Check if a key has expired
Sourcepub async fn get_expired_keys(&self) -> Result<Vec<TTLEntry>, MapletError>
pub async fn get_expired_keys(&self) -> Result<Vec<TTLEntry>, MapletError>
Get all expired keys
Sourcepub async fn start_cleanup<F>(
&self,
cleanup_callback: F,
) -> Result<(), MapletError>
pub async fn start_cleanup<F>( &self, cleanup_callback: F, ) -> Result<(), MapletError>
Start background cleanup task
Sourcepub async fn stop_cleanup(&self) -> Result<(), MapletError>
pub async fn stop_cleanup(&self) -> Result<(), MapletError>
Stop background cleanup task
Sourcepub async fn get_stats(&self) -> Result<TTLStats, MapletError>
pub async fn get_stats(&self) -> Result<TTLStats, MapletError>
Get TTL statistics
Sourcepub async fn clear_all(&self) -> Result<(), MapletError>
pub async fn clear_all(&self) -> Result<(), MapletError>
Clear all TTL entries
Auto Trait Implementations§
impl Freeze for TTLManager
impl !RefUnwindSafe for TTLManager
impl Send for TTLManager
impl Sync for TTLManager
impl Unpin for TTLManager
impl !UnwindSafe for TTLManager
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