Sigil documentation
ReferenceRust referencesigil-state

sigil-state · cache

Source declarations, signatures and documentation for cache.

Source: sigil/node/sigil-state/src/cache/mod.rs. SHA-256: e4f85e90674705ca900ce1c5950158c848e8c6a34c1291601dffad5d410035f5.

This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.

cache::StateCache

LRU cache for hot blockchain state. Designed for sub-microsecond cache hits using a doubly-linked list backed by a Vec arena plus a HashMap index.

Thread-safe via [parking_lot::RwLock] -- reads take a shared lock, writes (put/invalidate/eviction) take an exclusive lock.

#[derive(Debug)]
pub struct StateCache {

}

Source line: 13.

cache::CacheStats

Cache performance statistics.

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CacheStats {
pub hits: u64,
pub misses: u64,
pub size: usize,
pub capacity: usize
}

Source line: 22.

cache::CacheStats::hit_rate

Hit rate as a fraction in [0.0, 1.0]. Returns 0.0 if no accesses.

pub fn hit_rate(&self) -> f64;

Source line: 31.

cache::StateCache::new

Create a new cache with the given maximum capacity.

Panics

Does not panic. A capacity of 0 means no entries will ever be stored.

pub fn new(capacity: usize) -> Self;

Source line: 234.

cache::StateCache::get

Get a value from the cache. Returns None on a miss.

On hit, the entry is promoted to most-recently-used. This requires a write lock briefly for the promotion.

pub fn get(&self, key: &[u8]) -> Option<Vec<u8>>;

Source line: 247.

cache::StateCache::put

Put a key-value pair into the cache. If the cache is at capacity, the least-recently-used entry is evicted.

pub fn put(&self, key: Vec<u8>, value: Vec<u8>);

Source line: 263.

cache::StateCache::invalidate

Invalidate (remove) a key from the cache.

pub fn invalidate(&self, key: &[u8]);

Source line: 272.

cache::StateCache::stats

Get cache performance statistics.

pub fn stats(&self) -> CacheStats;

Source line: 278.

cache::StateCache::clear

Clear the entire cache and reset hit/miss counters.

pub fn clear(&self);

Source line: 289.

cache::StateCache::len

Current number of entries in the cache.

pub fn len(&self) -> usize;

Source line: 297.

cache::StateCache::is_empty

Whether the cache is empty.

pub fn is_empty(&self) -> bool;

Source line: 302.

On this page