internal static void CopyMetadata(ref Alachisoft.NCache.Web.Caching.CacheItem cacheItem, CachingOptions options, CacheDependency cacheDependency = null) { Logger.Log( "Copying options '" + options.ToLog() + "' into cache item metadata with CacheDependency '" + cacheDependency + "'.", Microsoft.Extensions.Logging.LogLevel.Trace ); // Set Expiration if (options.ExpirationType == ExpirationType.Absolute) { cacheItem.AbsoluteExpiration = options.AbsoluteExpirationTime; } else if (options.ExpirationType == ExpirationType.Sliding) { cacheItem.SlidingExpiration = options.SlidingExpirationTime; } // Set Priority cacheItem.Priority = options.Priority; // Set Cache Dependency if (options.CreateDbDependency) { cacheItem.Dependency = cacheDependency; } // Set Tags if (options.QueryIdentifier != null) { cacheItem.Tags = new Tag[] { options.QueryIdentifier }; } }
/// <summary> /// Applies the values of an existing <see cref="CachingOptions"/> to the entry. /// </summary> /// <param name="entry"></param> /// <param name="options"></param> internal static CacheEntry SetOptions(this CacheEntry entry, CachingOptions options) { Logger.Log( "Setting options '" + options.ToLog() + "'.", Microsoft.Extensions.Logging.LogLevel.Trace ); if (options == null) { throw new ArgumentNullException(nameof(options)); } entry.ExpirationType = options.ExpirationType; entry.AbsoluteExpirationTime = options.AbsoluteExpirationTime; entry.SlidingExpirationTime = options.SlidingExpirationTime; entry.Priority = options.Priority; entry.QueryIDentifier = options.QueryIdentifier == null ? default(string) : options.QueryIdentifier.ToString(); entry.CreateDbDependency = options.CreateDbDependency; return(entry); }
internal static void CopyMetadata(ref Alachisoft.NCache.Web.Caching.CacheItem cacheItem, CachingOptions options, CacheDependency cacheDependency = null) { Logger.Log( "Copying options '" + options.ToLog() + "' into cache item metadata with CacheDependency '" + cacheDependency + "'.", Microsoft.Extensions.Logging.LogLevel.Trace ); // Set Expiration if (options.ExpirationType == ExpirationType.Absolute) { cacheItem.AbsoluteExpiration = options.AbsoluteExpirationTime; } else if (options.ExpirationType == ExpirationType.Sliding) { cacheItem.SlidingExpiration = options.SlidingExpirationTime; } // Set Priority cacheItem.Priority = options.Priority; // Set Cache Dependency if (options.CreateDbDependency) { cacheItem.Dependency = cacheDependency; } //Set ReadThruProvider if (options.IsSyncEnabled) { if (!string.IsNullOrEmpty(options.ReadThruProvider)) { cacheItem.IsResyncExpiredItems = true; cacheItem.ResyncProviderName = options.ReadThruProvider; } } }