Add project files.
This commit is contained in:
		
							
								
								
									
										30
									
								
								Core.Blueprint.DAL.Redis/Helpers/CacheHelper.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								Core.Blueprint.DAL.Redis/Helpers/CacheHelper.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| using Core.Blueprint.DAL.Redis.Configuration; | ||||
|  | ||||
| namespace Core.Blueprint.DAL.Redis.Helpers | ||||
| { | ||||
|     public static class CacheHelper | ||||
|     { | ||||
|         /// <summary> | ||||
|         /// Determines the cache duration based on specific duration, settings, or a default value. | ||||
|         /// </summary> | ||||
|         /// <param name="specificCacheDuration">Specific cache duration in minutes, if provided.</param> | ||||
|         /// <param name="cacheSettings">General cache settings containing default duration values.</param> | ||||
|         /// <returns>The cache duration as a TimeSpan.</returns> | ||||
|         public static TimeSpan GetCacheDuration(CacheSettings cacheSettings, int? specificCacheDuration = 0) | ||||
|         { | ||||
|             var defaultCacheDuration = TimeSpan.FromMinutes(.5); | ||||
|  | ||||
|             if (specificCacheDuration.HasValue && specificCacheDuration.Value > 0) | ||||
|             { | ||||
|                 return TimeSpan.FromMinutes(specificCacheDuration.Value); | ||||
|             } | ||||
|  | ||||
|             if (cacheSettings.DefaultCacheDurationInMinutes > 0) | ||||
|             { | ||||
|                 return TimeSpan.FromMinutes(cacheSettings.DefaultCacheDurationInMinutes); | ||||
|             } | ||||
|  | ||||
|             return defaultCacheDuration; | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Sergio Matias Urquin
					Sergio Matias Urquin