/// <summary> /// Creates a unique cache partition that may share references to objects with same key/versions with other partitions /// </summary> /// <returns>Partitioned cache</returns> public ICache <TKey, TResource> CreatePartition() { lock (_lock) { var view = new CacheView(this); _views.Add(view); return(view); } }
private void Remove(VersionResourceKey versionedKey, CacheView originView) { var otherViewsTrackingResource = _views .Except(new[] { originView }) .Any(x => x.TryGetValue(versionedKey.Key, out var resource) && _versionSelector(resource).Equals(versionedKey.Version)); if (!otherViewsTrackingResource) { Items.Remove(versionedKey); } }
private static CacheView RenderAndCacheForcibly( Controller controller, IView view, string cacheKey, int duration) { CacheView cacheView; lock (ObjectLocker.Instance.GetLockObject(cacheKey)) { cacheView = new CacheView(Render(controller, view)); controller.HttpContext.Cache.Insert( cacheKey, cacheView, null, DateTime.Now.AddSeconds(duration), Cache.NoSlidingExpiration); } return(cacheView); }
private void Remove(TResource resource, CacheView originView) { var versionedKey = GetVersionKeyFor(resource); Remove(versionedKey, originView); }