diff --git a/foyer-memory/src/cache.rs b/foyer-memory/src/cache.rs index c44818d5..47faf6be 100644 --- a/foyer-memory/src/cache.rs +++ b/foyer-memory/src/cache.rs @@ -401,14 +401,13 @@ where } /// Build in-memory cache with the given configuration. - pub fn build(mut self) -> Cache { + pub fn build(self) -> Cache { if self.capacity < self.shards { tracing::warn!( - "The in-memory cache capacity({}) < shards({})", + "The in-memory cache capacity({}) < shards({}).", self.capacity, self.shards ); - self.shards = 1; } match self.eviction_config { @@ -889,12 +888,6 @@ mod tests { const OPS: usize = 10000; const CONCURRENCY: usize = 8; - #[test] - fn test_not_enough_capacity() { - let cache: Cache = CacheBuilder::new(4).with_shards(64).build(); - assert_eq!(cache.shards(), 1); - } - fn fifo() -> Cache { CacheBuilder::new(CAPACITY) .with_shards(SHARDS) diff --git a/foyer-memory/src/generic.rs b/foyer-memory/src/generic.rs index d2625836..21fdef60 100644 --- a/foyer-memory/src/generic.rs +++ b/foyer-memory/src/generic.rs @@ -497,8 +497,6 @@ where S: HashBuilder, { pub fn new(config: GenericCacheConfig) -> Self { - assert!(config.capacity >= config.shards); - let metrics = Arc::new(Metrics::new(&config.name)); let usages = (0..config.shards).map(|_| Arc::new(AtomicUsize::new(0))).collect_vec();