Пример #1
0
        protected virtual async Task OnItemExpiredAsync(string key)
        {
            var args = new ItemExpiredEventArgs {
                Client = this,
                Key    = key
            };

            await(ItemExpired?.InvokeAsync(this, args) ?? Task.CompletedTask).AnyContext();
        }
Пример #2
0
        private Task OnItemExpiredAsync(string key, bool sendNotification = true)
        {
            var args = new ItemExpiredEventArgs {
                Client           = this,
                Key              = key,
                SendNotification = sendNotification
            };

            return(ItemExpired?.InvokeAsync(this, args) ?? Task.CompletedTask);
        }
Пример #3
0
        private async Task OnItemExpiredAsync(string key, bool sendNotification = true)
        {
            var args = new ItemExpiredEventArgs {
                Client           = this,
                Key              = key,
                SendNotification = sendNotification
            };

            await(ItemExpired?.InvokeAsync(this, args) ?? Task.CompletedTask).AnyContext();
        }
Пример #4
0
        private async Task OnLocalCacheItemExpiredAsync(object sender, ItemExpiredEventArgs args)
        {
            if (!args.SendNotification)
            {
                return;
            }

            _logger.Trace("Local cache expired event: key={0}", args.Key);
            await _messageBus.PublishAsync(new InvalidateCache { CacheId = _cacheId, Keys = new[] { args.Key }, Expired = true }).AnyContext();
        }
Пример #5
0
        private Task OnLocalCacheItemExpiredAsync(object sender, ItemExpiredEventArgs args)
        {
            if (!args.SendNotification)
            {
                return(Task.CompletedTask);
            }

            if (_logger.IsEnabled(LogLevel.Trace))
            {
                _logger.LogTrace("Local cache expired event: key={Key}", args.Key);
            }
            return(_messageBus.PublishAsync(new InvalidateCache {
                CacheId = _cacheId, Keys = new[] { args.Key }, Expired = true
            }));
        }
Пример #6
0
        private void OnItemExpiredAsync(string key, bool sendNotification = true)
        {
            if (ItemExpired == null)
            {
                return;
            }

            Task.Factory.StartNew(state => {
                var args = new ItemExpiredEventArgs {
                    Client           = this,
                    Key              = key,
                    SendNotification = sendNotification
                };

                return(ItemExpired.InvokeAsync(this, args));
            }, this, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
        }