Skip to content

Commit

Permalink
separate ordered trait
Browse files Browse the repository at this point in the history
  • Loading branch information
just-in-chang committed Mar 7, 2024
1 parent e08c95f commit f78c7c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion crates/aptos-in-memory-cache/src/caches/s3fifo.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

use crate::Cache;
use crate::{Cache, Ordered};
use quick_cache::{sync::Cache as S3FIFOCache, Lifecycle, Weighter};
use std::hash::{BuildHasher, Hash};

Expand All @@ -20,7 +20,16 @@ where
fn insert(&mut self, key: K, value: V) {
S3FIFOCache::insert(self, key, value);
}
}

impl<K, V, We, B, L> Ordered<K, V> for S3FIFOCache<K, V, We, B, L>
where
K: Eq + Hash + Clone + Send + Sync,
V: Clone + Send + Sync,
We: Weighter<K, V> + Clone + Send + Sync,
B: BuildHasher + Clone + Send + Sync,
L: Lifecycle<K, V> + Clone + Send + Sync,
{
fn first_key(&self) -> Option<K> {
unimplemented!();
}
Expand Down
2 changes: 2 additions & 0 deletions crates/aptos-in-memory-cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ where

/// Inserts a given key-value pair in cache. Panics if the insert fails.
fn insert(&mut self, key: K, value: V);
}

pub trait Ordered<K, V>: Send + Sync {
/// Returns the first key in the cache. Returns [`None`] if the cache is empty.
fn first_key(&self) -> Option<K>;

Expand Down

0 comments on commit f78c7c7

Please sign in to comment.