@@ -373,7 +373,6 @@ public RuntimeConfig(
373373 }
374374
375375 SetupDataSourcesUsed ( ) ;
376-
377376 }
378377
379378 /// <summary>
@@ -529,12 +528,13 @@ Runtime is not null && Runtime.Host is not null
529528
530529 /// <summary>
531530 /// Returns the ttl-seconds value for a given entity.
532- /// If the property is not set, returns the global default value set in the runtime config.
533- /// If the global default value is not set, the default value is used (5 seconds).
531+ /// If the entity explicitly sets ttl-seconds, that value is used.
532+ /// Otherwise, falls back to the global cache TTL setting.
533+ /// Callers are responsible for checking whether caching is enabled before using the result.
534534 /// </summary>
535535 /// <param name="entityName">Name of the entity to check cache configuration.</param>
536536 /// <returns>Number of seconds (ttl) that a cache entry should be valid before cache eviction.</returns>
537- /// <exception cref="DataApiBuilderException">Raised when an invalid entity name is provided or if the entity has caching disabled .</exception>
537+ /// <exception cref="DataApiBuilderException">Raised when an invalid entity name is provided.</exception>
538538 public virtual int GetEntityCacheEntryTtl ( string entityName )
539539 {
540540 if ( ! Entities . TryGetValue ( entityName , out Entity ? entityConfig ) )
@@ -545,31 +545,23 @@ public virtual int GetEntityCacheEntryTtl(string entityName)
545545 subStatusCode : DataApiBuilderException . SubStatusCodes . EntityNotFound ) ;
546546 }
547547
548- if ( ! entityConfig . IsCachingEnabled )
549- {
550- throw new DataApiBuilderException (
551- message : $ "{ entityName } does not have caching enabled.",
552- statusCode : HttpStatusCode . BadRequest ,
553- subStatusCode : DataApiBuilderException . SubStatusCodes . NotSupported ) ;
554- }
555-
556- if ( entityConfig . Cache . UserProvidedTtlOptions )
548+ if ( entityConfig . Cache is not null && entityConfig . Cache . UserProvidedTtlOptions )
557549 {
558550 return entityConfig . Cache . TtlSeconds . Value ;
559551 }
560- else
561- {
562- return GlobalCacheEntryTtl ( ) ;
563- }
552+
553+ return GlobalCacheEntryTtl ( ) ;
564554 }
565555
566556 /// <summary>
567557 /// Returns the cache level value for a given entity.
568- /// If the property is not set, returns the default (L1L2) for a given entity.
558+ /// If the entity explicitly sets level, that value is used.
559+ /// Otherwise, falls back to the global cache level or the default.
560+ /// Callers are responsible for checking whether caching is enabled before using the result.
569561 /// </summary>
570562 /// <param name="entityName">Name of the entity to check cache configuration.</param>
571563 /// <returns>Cache level that a cache entry should be stored in.</returns>
572- /// <exception cref="DataApiBuilderException">Raised when an invalid entity name is provided or if the entity has caching disabled .</exception>
564+ /// <exception cref="DataApiBuilderException">Raised when an invalid entity name is provided.</exception>
573565 public virtual EntityCacheLevel GetEntityCacheEntryLevel ( string entityName )
574566 {
575567 if ( ! Entities . TryGetValue ( entityName , out Entity ? entityConfig ) )
@@ -580,22 +572,12 @@ public virtual EntityCacheLevel GetEntityCacheEntryLevel(string entityName)
580572 subStatusCode : DataApiBuilderException . SubStatusCodes . EntityNotFound ) ;
581573 }
582574
583- if ( ! entityConfig . IsCachingEnabled )
584- {
585- throw new DataApiBuilderException (
586- message : $ "{ entityName } does not have caching enabled.",
587- statusCode : HttpStatusCode . BadRequest ,
588- subStatusCode : DataApiBuilderException . SubStatusCodes . NotSupported ) ;
589- }
590-
591- if ( entityConfig . Cache . UserProvidedLevelOptions )
575+ if ( entityConfig . Cache is not null && entityConfig . Cache . UserProvidedLevelOptions )
592576 {
593577 return entityConfig . Cache . Level . Value ;
594578 }
595- else
596- {
597- return EntityCacheLevel . L1L2 ;
598- }
579+
580+ return EntityCacheOptions . DEFAULT_LEVEL ;
599581 }
600582
601583 /// <summary>
0 commit comments