Skip to content

Commit

Permalink
with_capacity facade function support
Browse files Browse the repository at this point in the history
  • Loading branch information
abdolence committed Oct 6, 2023
1 parent 4304b47 commit 384e664
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/cache/backends/memory_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,20 @@ pub struct FirestoreMemoryCacheBackend {
collection_caches: HashMap<String, FirestoreMemCache>,
}

const FIRESTORE_MEMORY_CACHE_DEFAULT_MAX_CAPACITY: u64 = 50000;

impl FirestoreMemoryCacheBackend {
pub fn new(config: FirestoreCacheConfiguration) -> FirestoreResult<Self> {
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> {
Self::with_collection_options(config, |_| {
FirestoreMemCache::builder().max_capacity(max_capacity)
})
}

pub fn with_collection_options<FN>(
Expand Down

0 comments on commit 384e664

Please sign in to comment.