InodeLruCache

Struct InodeLruCache 

Source
struct InodeLruCache {
    map: HashMap<u32, u32>,
    nodes: HashMap<u32, InodeLruNode>,
    head: Option<u32>,
    tail: Option<u32>,
    next_id: u32,
    max_size: usize,
    hits: u64,
    misses: u64,
    access_counter: u64,
}
Expand description

O(1) LRU cache implementation for inodes using HashMap + doubly-linked list

Fields§

§map: HashMap<u32, u32>

Map from inode number to node ID

§nodes: HashMap<u32, InodeLruNode>

Storage for all nodes

§head: Option<u32>

Head of doubly-linked list (most recently used)

§tail: Option<u32>

Tail of doubly-linked list (least recently used)

§next_id: u32

Next available node ID

§max_size: usize

Maximum cache size

§hits: u64

Cache statistics

§misses: u64§access_counter: u64

Access counter for approximate LRU

Implementations§

Source§

impl InodeLruCache

Source

fn new(max_size: usize) -> Self

Source

fn get(&mut self, inode_num: u32) -> Option<Ext2Inode>

O(1) get operation with LRU update

Source

fn insert(&mut self, inode_num: u32, inode: Ext2Inode)

O(1) insert operation with LRU eviction

Source

fn remove(&mut self, inode_num: u32)

O(1) remove operation

Source

fn move_to_head(&mut self, node_id: u32)

O(1) move node to head of LRU list

Source

fn remove_tail(&mut self)

O(1) remove tail (LRU) node

Source

fn remove_node(&mut self, node_id: u32)

O(1) remove node completely

Source

fn remove_node_from_list(&mut self, node_id: u32)

O(1) remove node from doubly-linked list (but keep in nodes map)

Source

fn len(&self) -> usize

Source

fn get_stats(&self) -> (u64, u64, usize)

Get cache statistics for debugging and performance analysis

Source

fn print_stats(&self, cache_name: &str)

Print cache statistics

Auto Trait Implementations§

§

impl Freeze for InodeLruCache

§

impl RefUnwindSafe for InodeLruCache

§

impl Send for InodeLruCache

§

impl Sync for InodeLruCache

§

impl Unpin for InodeLruCache

§

impl UnwindSafe for InodeLruCache

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.