/// <summary> /// Set the specified cacheKey, cacheValue and expiration. /// </summary> /// <returns>The set.</returns> /// <param name="cacheKey">Cache key.</param> /// <param name="cacheValue">Cache value.</param> /// <param name="expiration">expiration.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> public void Set <T>(string cacheKey, T cacheValue, TimeSpan expiration) where T : class { ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey)); ArgumentCheck.NotNull(cacheValue, nameof(cacheValue)); ArgumentCheck.NotNegativeOrZero(expiration, nameof(expiration)); _cache.Set(cacheKey, cacheValue, expiration); _cacheKeys.Add(cacheKey); }
/// <summary> /// Set the specified cacheKey, cacheValue and expiration. /// </summary> /// <returns>The set.</returns> /// <param name="cacheKey">Cache key.</param> /// <param name="cacheValue">Cache value.</param> /// <param name="expiration">expiration.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> public void Set <T>(string cacheKey, T cacheValue, TimeSpan expiration) where T : class { ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey)); ArgumentCheck.NotNull(cacheValue, nameof(cacheValue)); ArgumentCheck.NotNegativeOrZero(expiration, nameof(expiration)); if (MaxRdSecond > 0) { var addSec = new Random().Next(1, MaxRdSecond); expiration.Add(new TimeSpan(0, 0, addSec)); } _cache.Set(cacheKey, cacheValue, expiration); _cacheKeys.Add(cacheKey); }