Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
make lru cache generic
Browse files Browse the repository at this point in the history
  • Loading branch information
xx01cyx committed Feb 18, 2024
1 parent 9fffa88 commit 8bb54f3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions storage-node/src/cache/lru.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
use std::collections::HashMap;

use datafusion::execution::DiskManager;

use super::{ParpulseCache, ParpulseCacheKey, ParpulseCacheValue};

// Just an example. Feel free to modify.
pub struct LruCache {}
pub struct LruCache<K, V> {
kv: HashMap<K, V>,
}

impl LruCache {
impl<K, V> LruCache<K, V> {
pub fn new() -> Self {
Self {}
Self { kv: HashMap::new() }
}

pub fn get(&mut self, key: &ParpulseCacheKey) -> Option<ParpulseCacheValue> {
pub fn get(&mut self, key: &K) -> Option<V> {
todo!()
}

pub fn put(&mut self, key: ParpulseCacheKey, value: ParpulseCacheValue) -> bool {
pub fn put(&mut self, key: K, value: V) -> bool {
todo!()
}

pub fn pop(&mut self) -> Option<ParpulseCacheValue> {
pub fn pop(&mut self) -> Option<V> {
todo!()
}
}

impl ParpulseCache for LruCache {
impl ParpulseCache for LruCache<ParpulseCacheKey, ParpulseCacheValue> {
fn get_value(&mut self, key: &ParpulseCacheKey) -> Option<ParpulseCacheValue> {
self.get(key)
}
Expand Down

0 comments on commit 8bb54f3

Please sign in to comment.