public virtual void Add(string cacheKey, object value, CacheOptions options = null) { if (options == null) { options = new CacheOptions(); } context.HttpContext.Cache.Add(tablePrefix + cacheKey, value, GetCacheDependency(options), options.AbsoluteExpiration, options.SlidingExpiration, options.Priority, options.RemoveCallback); }
public virtual T GetOrCreate <T>(string cacheKey, Func <T> factory, CacheOptions options = null) where T : class { var value = Get <T>(cacheKey); if (value != null) { return(value); } value = factory(); Add(cacheKey, value, options); return(value); }
public virtual CacheDependency GetCacheDependency(CacheOptions options) { if (!options.ContentDependency) { return(null); } if (string.IsNullOrEmpty(sqlCacheDependency)) { return(new ContentCacheDependency(persister)); // TODO ensure proper eviction with XML repo } return(new SqlCacheDependency(sqlCacheDependency, tablePrefix + "Item")); }
protected virtual CacheDependency GetCacheDependency(CacheOptions options) { if (!options.ContentDependency) { return(null); } if (string.IsNullOrEmpty(sqlCacheDependency)) { return(new ContentCacheDependency(persister)); } return(new SqlCacheDependency(sqlCacheDependency, tablePrefix + "item")); }