Skip to content

Conversation

@pushkarm029
Copy link
Collaborator

No description provided.

Signed-off-by: Pushkar Mishra <[email protected]>
Comment on lines +3 to +16
pub struct CacheEntry<K, V> {
value: V,
size: usize,
top: Option<K>,
bottom: Option<K>,
}

pub struct LRUCache<K, V> {
entries: HashMap<K, CacheEntry<K, V>>,
head: Option<K>,
tail: Option<K>,
memory_used: usize,
max_memory: usize,
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To remove few expensive clones, we can consider this later:

pub struct CacheEntry<V> {
    value: V,
    size: usize,
    top: Option<usize>,
    bottom: Option<usize>,
    id: usize,
}

pub struct LRUCache<K, V> {
    entries: HashMap<K, CacheEntry<V>>,
    keys: HashMap<usize, K>,
    head: Option<usize>,
    tail: Option<usize>,
    memory_used: usize,
    max_memory: usize,
    id_counter: usize,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants