@@ -81,10 +81,11 @@ pub struct NextConfig {
8181 config_file : Option < RcStr > ,
8282 config_file_name : RcStr ,
8383
84+ cache_life : Option < JsonValue > ,
8485 /// In-memory cache size in bytes.
8586 ///
8687 /// If `cache_max_memory_size: 0` disables in-memory caching.
87- cache_max_memory_size : Option < f64 > ,
88+ cache_max_memory_size : Option < JsonValue > ,
8889 /// custom path to a cache handler to use
8990 cache_handler : Option < RcStr > ,
9091 cache_handlers : Option < FxIndexMap < RcStr , RcStr > > ,
@@ -835,7 +836,6 @@ pub struct ExperimentalConfig {
835836 adjust_font_fallbacks_with_size_adjust : Option < bool > ,
836837 after : Option < bool > ,
837838 app_document_preloading : Option < bool > ,
838- cache_life : Option < FxIndexMap < String , CacheLifeProfile > > ,
839839 case_sensitive_routes : Option < bool > ,
840840 cpus : Option < f64 > ,
841841 cra_compat : Option < bool > ,
@@ -908,63 +908,6 @@ pub struct ExperimentalConfig {
908908 devtool_segment_explorer : Option < bool > ,
909909}
910910
911- #[ derive(
912- Clone , Debug , PartialEq , Serialize , Deserialize , TraceRawVcs , NonLocalValue , OperationValue ,
913- ) ]
914- #[ serde( rename_all = "camelCase" ) ]
915- pub struct CacheLifeProfile {
916- #[ serde( skip_serializing_if = "Option::is_none" ) ]
917- pub stale : Option < u32 > ,
918- #[ serde( skip_serializing_if = "Option::is_none" ) ]
919- pub revalidate : Option < u32 > ,
920- #[ serde( skip_serializing_if = "Option::is_none" ) ]
921- pub expire : Option < u32 > ,
922- }
923-
924- #[ test]
925- fn test_cache_life_profiles ( ) {
926- let json = serde_json:: json!( {
927- "cacheLife" : {
928- "frequent" : {
929- "stale" : 19 ,
930- "revalidate" : 100 ,
931- } ,
932- }
933- } ) ;
934-
935- let config: ExperimentalConfig = serde_json:: from_value ( json) . unwrap ( ) ;
936- let mut expected_cache_life = FxIndexMap :: default ( ) ;
937-
938- expected_cache_life. insert (
939- "frequent" . to_string ( ) ,
940- CacheLifeProfile {
941- stale : Some ( 19 ) ,
942- revalidate : Some ( 100 ) ,
943- expire : None ,
944- } ,
945- ) ;
946-
947- assert_eq ! ( config. cache_life, Some ( expected_cache_life) ) ;
948- }
949-
950- #[ test]
951- fn test_cache_life_profiles_invalid ( ) {
952- let json = serde_json:: json!( {
953- "cacheLife" : {
954- "invalid" : {
955- "stale" : "invalid_value" ,
956- } ,
957- }
958- } ) ;
959-
960- let result: Result < ExperimentalConfig , _ > = serde_json:: from_value ( json) ;
961-
962- assert ! (
963- result. is_err( ) ,
964- "Deserialization should fail due to invalid 'stale' value type"
965- ) ;
966- }
967-
968911#[ derive(
969912 Clone , Debug , PartialEq , Eq , Serialize , Deserialize , TraceRawVcs , NonLocalValue , OperationValue ,
970913) ]
@@ -1312,6 +1255,16 @@ impl NextConfig {
13121255 Vc :: cell ( self . base_path . clone ( ) )
13131256 }
13141257
1258+ #[ turbo_tasks:: function]
1259+ pub fn cache_life ( & self ) -> Vc < OptionJsonValue > {
1260+ Vc :: cell ( self . cache_life . clone ( ) )
1261+ }
1262+
1263+ #[ turbo_tasks:: function]
1264+ pub fn cache_max_memory_size ( & self ) -> Vc < OptionJsonValue > {
1265+ Vc :: cell ( self . cache_max_memory_size . clone ( ) )
1266+ }
1267+
13151268 #[ turbo_tasks:: function]
13161269 pub fn cache_handler ( & self , project_path : FileSystemPath ) -> Result < Vc < OptionFileSystemPath > > {
13171270 if let Some ( handler) = & self . cache_handler {
0 commit comments