11use std:: collections:: BTreeMap ;
22use std:: fmt:: Display ;
3- use std:: num:: NonZeroUsize ;
43
54use apollo_config:: dumping:: { prepend_sub_config_name, ser_param, SerializeConfig } ;
65use apollo_config:: { ParamPath , ParamPrivacyInput , SerializedParam } ;
@@ -23,7 +22,7 @@ use crate::storage_trait::{
2322} ;
2423
2524// 1M entries.
26- const DEFAULT_CACHE_SIZE : usize = 1000000 ;
25+ const DEFAULT_CACHE_SIZE : u64 = 1000000 ;
2726
2827#[ derive( Debug , Default , PartialEq , Serialize ) ]
2928pub struct MapStorage ( pub DbHashMap ) ;
@@ -85,7 +84,7 @@ pub struct CachedStorage<S: Storage> {
8584#[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
8685pub struct CachedStorageConfig < InnerStorageConfig : StorageConfigTrait > {
8786 // Max number of entries in the cache.
88- pub cache_size : NonZeroUsize , // TODO(Nimrod): Change type to ` u64`.
87+ pub cache_size : u64 ,
8988
9089 // If true, the cache is updated on write operations even if the value is not in the cache.
9190 pub cache_on_write : bool ,
@@ -100,7 +99,7 @@ pub struct CachedStorageConfig<InnerStorageConfig: StorageConfigTrait> {
10099impl < InnerStorageConfig : StorageConfigTrait > Default for CachedStorageConfig < InnerStorageConfig > {
101100 fn default ( ) -> Self {
102101 Self {
103- cache_size : NonZeroUsize :: new ( DEFAULT_CACHE_SIZE ) . unwrap ( ) ,
102+ cache_size : DEFAULT_CACHE_SIZE ,
104103 cache_on_write : true ,
105104 include_inner_stats : true ,
106105 inner_storage_config : InnerStorageConfig :: default ( ) ,
@@ -203,9 +202,7 @@ impl<S: Storage> CachedStorage<S> {
203202 // TODO(Nimrod): Consider defining custom eviction policies.
204203 Self {
205204 storage,
206- cache : Cache :: builder ( )
207- . max_capacity ( config. cache_size . get ( ) . try_into ( ) . unwrap ( ) )
208- . build ( ) ,
205+ cache : Cache :: builder ( ) . max_capacity ( config. cache_size ) . build ( ) ,
209206 cache_on_write : config. cache_on_write ,
210207 reads : 0 ,
211208 cached_reads : 0 ,
0 commit comments