From 384e664e79acd325f769f2fdc69a370a1e563d35 Mon Sep 17 00:00:00 2001 From: Abdulla Abdurakhmanov Date: Fri, 6 Oct 2023 14:51:30 +0200 Subject: [PATCH] with_capacity facade function support --- src/cache/backends/memory_backend.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cache/backends/memory_backend.rs b/src/cache/backends/memory_backend.rs index 22c9140..bad9814 100644 --- a/src/cache/backends/memory_backend.rs +++ b/src/cache/backends/memory_backend.rs @@ -18,9 +18,20 @@ pub struct FirestoreMemoryCacheBackend { collection_caches: HashMap, } +const FIRESTORE_MEMORY_CACHE_DEFAULT_MAX_CAPACITY: u64 = 50000; + impl FirestoreMemoryCacheBackend { pub fn new(config: FirestoreCacheConfiguration) -> FirestoreResult { - Self::with_collection_options(config, |_| FirestoreMemCache::builder().max_capacity(10000)) + Self::with_max_capacity(config, FIRESTORE_MEMORY_CACHE_DEFAULT_MAX_CAPACITY) + } + + pub fn with_max_capacity( + config: FirestoreCacheConfiguration, + max_capacity: u64, + ) -> FirestoreResult { + Self::with_collection_options(config, |_| { + FirestoreMemCache::builder().max_capacity(max_capacity) + }) } pub fn with_collection_options(