/// <summary> /// Removes the data associated with the <paramref name="cacheItemId"/> from the cache. /// </summary> /// <param name="cacheItemId">The cache item ID for the cache item.</param> public static void RemoveCache(CacheItem cacheItemId) { CacheManager.Remove(cacheItemId.ToString()); }
/// <summary> /// Adds the <paramref name="cacheItem"/> to the cache named <paramref name="cacheItemId"/> and set to an absolute expiration /// time specified in <paramref name="dateTimeOffset"/>. If it exists it is overwritten. /// If <paramref name="cacheItem"/> is null, any existing cache named <paramref name="cacheItemId"/> is deleted. /// If caching is disabled (<see cref="IAppSetting.EnableCache" />=<c>false</c>), then no action is taken. /// </summary> /// <param name="cacheItemId">The cache item ID for the cache item.</param> /// <param name="cacheItem">The item to be stored in cache.</param> /// <param name="dateTimeOffset">The fixed date and time at which the cache entry will expire.</param> public static void SetCache(CacheItem cacheItemId, object cacheItem, DateTimeOffset dateTimeOffset) { if (!AppSetting.Instance.EnableCache) return; if (cacheItem != null) { CacheManager.Add(cacheItemId.ToString(), cacheItem, dateTimeOffset); } else { CacheManager.Remove(cacheItemId.ToString()); } }
/// <summary> /// Gets the data stored in cache that has the name <paramref name="cacheItemId"/>. Returns null if no data is in the cache. /// </summary> /// <param name="cacheItemId">The cache item ID for the cache item.</param> /// <returns>Returns the data stored in cache that has the name <paramref name="cacheItemId"/>.</returns> public static object GetCache(CacheItem cacheItemId) { return CacheManager.Get(cacheItemId.ToString()); }