private void Publish(TKey keyToInvalidate) { if (_layer1NotificationsProvider == null) { _cacheNotificationsRouter?.Publish <TValue>(_keySerializer(keyToInvalidate)); } }
private void SubscribeToCacheNotifications() { _layer2NotificationsProvider?.Subscribe(InvalidateLayer1Keys); //if layer2 notifications are available invalidate layer 1 with them if (_cacheNotificationsRouter != null) { _layer1NotificationsProvider?.Subscribe(k => _cacheNotificationsRouter.Publish <TValue>(_keySerializer(k))); } //if layer 1 notifications available, propagate them to the router that external client may subscribe to //otherwise will be handled after invalidation }
private void HandleKeyEvents(string key, KeyEvent eventType) { switch (eventType) { case KeyEvent.Delete: case KeyEvent.Expire: case KeyEvent.Evicted: //TODO: how to handle expiration set and set (updates) properly here? These events are also fired when item is created. Need to find a way to not remove it from layer1 right after loading //case KeyEvent.ExpirationSet: //case KeyEvent.Set: _notificationsRouter.Publish <TKey, TValue>(ExtractKeyFromString(key), _keySerializer); break; default: return; } }
private void Publish(TKey key) { _notificationsRouter?.Publish <TValue>(_keySerializer(key)); }