public void UnregisterRemoteCacheDependency(string cacheKey) { if (!string.IsNullOrEmpty(cacheKey)) { lock (_remoteCacheKeys) { if (_remoteCacheKeys.ContainsKey(cacheKey)) { CacheKeyStats cacheKeyCounter = _remoteCacheKeys[cacheKey]; if (cacheKeyCounter != null) { cacheKeyCounter.refCount--; if (cacheKeyCounter.refCount == 0) { _remoteCacheKeys.Remove(cacheKey); } } } } lock (_registerCallbackQueue) { ThreadTask registerThread = new ThreadTask(cacheKey, false, true); _registerCallbackQueue.Enqueue(registerThread); Monitor.Pulse(_registerCallbackQueue); } } }
private void SetItemExpiration(string cacheKey, string reason) { if (!string.IsNullOrEmpty(cacheKey)) { if (_remoteCacheKeys.ContainsKey(cacheKey)) { CacheKeyStats cacheStatus = _remoteCacheKeys[cacheKey]; if (cacheStatus != null) { lock (_remoteCacheKeys) { cacheStatus.HasExpired = true; //SET Boolean } } } } }
public void RegisterRemoteCacheDependency(string cacheKey) { if (!string.IsNullOrEmpty(cacheKey)) { bool isNewKey = false; lock (_remoteCacheKeys) { if (_remoteCacheKeys.ContainsKey(cacheKey)) { CacheKeyStats cacheStats = _remoteCacheKeys[cacheKey]; if (cacheStats != null) { cacheStats.refCount++; cacheStats.HasExpired = false; } else { cacheStats = new CacheKeyStats(); cacheStats.refCount = 1; cacheStats.HasExpired = false; } } else { CacheKeyStats cacheStats = new CacheKeyStats(); cacheStats.refCount = 1; cacheStats.HasExpired = false; _remoteCacheKeys.Add(cacheKey, cacheStats); isNewKey = true; } } if (isNewKey) { lock (_registerCallbackQueue) { ThreadTask registerThread = new ThreadTask(cacheKey, true, false); _registerCallbackQueue.Enqueue(registerThread); Monitor.Pulse(_registerCallbackQueue); } } } }