pub struct Cache<K, V> { /* private fields */ }
Expand description
High-performance cache with TTL and LRU eviction
Implementations§
Source§impl<K, V> Cache<K, V>
impl<K, V> Cache<K, V>
Sourcepub fn new(config: CacheConfig) -> Self
pub fn new(config: CacheConfig) -> Self
Create a new cache with the given configuration
Sourcepub async fn insert_with_ttl(&self, key: K, value: V, ttl: Duration)
pub async fn insert_with_ttl(&self, key: K, value: V, ttl: Duration)
Insert a value into the cache with custom TTL
Sourcepub async fn stats(&self) -> CacheStats
pub async fn stats(&self) -> CacheStats
Get cache statistics
Sourcepub async fn cleanup_expired(&self)
pub async fn cleanup_expired(&self)
Clean up expired entries
Sourcepub async fn contains_key(&self, key: &K) -> bool
pub async fn contains_key(&self, key: &K) -> bool
Check if cache contains a key
Sourcepub fn start_cleanup_task(&self) -> JoinHandle<()>
pub fn start_cleanup_task(&self) -> JoinHandle<()>
Start background cleanup task
Source§impl Cache<String, Value>
impl Cache<String, Value>
Sourcepub fn new_rpc_cache() -> Self
pub fn new_rpc_cache() -> Self
Create a new RPC cache with optimized settings
Sourcepub async fn cache_block(&self, identifier: String, block: Value)
pub async fn cache_block(&self, identifier: String, block: Value)
Cache a block by hash or index
Sourcepub async fn cache_transaction(&self, tx_hash: String, transaction: Value)
pub async fn cache_transaction(&self, tx_hash: String, transaction: Value)
Cache a transaction by hash
Sourcepub async fn cache_contract_state(&self, contract_hash: String, state: Value)
pub async fn cache_contract_state(&self, contract_hash: String, state: Value)
Cache contract state
Sourcepub async fn cache_balance(&self, address: String, balance: Value)
pub async fn cache_balance(&self, address: String, balance: Value)
Cache balance information
Auto Trait Implementations§
impl<K, V> Freeze for Cache<K, V>
impl<K, V> !RefUnwindSafe for Cache<K, V>
impl<K, V> Send for Cache<K, V>
impl<K, V> Sync for Cache<K, V>
impl<K, V> Unpin for Cache<K, V>
impl<K, V> !UnwindSafe for Cache<K, V>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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