Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs-cache: Add LRU Struct #98

Draft
wants to merge 1 commit into
base: cache
Choose a base branch
from
Draft

fs-cache: Add LRU Struct #98

wants to merge 1 commit into from

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.

1 participant