/// <summary> /// Removes <see cref="SafeNamedCache"/> from the /// <see cref="ScopedReferenceStore"/>. /// </summary> /// <param name="cacheSafe"> /// <b>SafeNamedCache</b> to be removed. /// </param> protected virtual void RemoveCacheReference(SafeNamedCache cacheSafe) { cacheSafe.IsReleased = true; ScopedReferenceStore storeCache = StoreSafeNamedCache; lock (storeCache) { storeCache.ReleaseCache(cacheSafe); } }
/// <summary> /// Release local resources associated with the specified instance of /// the cache. /// </summary> /// <remarks> /// <p> /// This invalidates a reference obtained by using the /// <see cref="ICacheService.EnsureCache"/> method.</p> /// <p> /// Releasing a reference to a cache makes the cache reference no /// longer usable, but does not affect the cache itself. In other /// words, all other references to the cache will still be valid, and /// the cache data is not affected by releasing the reference.</p> /// <p> /// The reference that is released using this method can no longer be /// used; any attempt to use the reference will result in an /// exception.</p> /// </remarks> /// <param name="cache"> /// The cache object to be released. /// </param> public virtual void ReleaseCache(INamedCache cache) { if (!(cache is RemoteNamedCache)) { throw new ArgumentException("illegal cache: " + cache); } ScopedReferenceStore storeCache = StoreRemoteNamedCache; lock (storeCache) { storeCache.ReleaseCache(cache); } ReleaseRemoteNamedCache(cache as RemoteNamedCache); }