public async Task <IEnumerable <WeatherForecast> > Get()
        {
            var rng = new Random();

            await _redis.GetSubscriber().PublishAsync("ConfigurationUpdate", true);

            return(Enumerable.Range(1, 5).Select(index => new WeatherForecast
            {
                Date = DateTime.Now.AddDays(index),
                TemperatureC = rng.Next(-20, 55),
                Summary = Summaries[rng.Next(Summaries.Length)]
            })
                   .ToArray());
        }
示例#2
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            _appLifetime.ApplicationStarted.Register(OnStarted);
            _appLifetime.ApplicationStopping.Register(OnStopping);
            _appLifetime.ApplicationStopped.Register(OnStopped);

            await _redis.GetSubscriber().SubscribeAsync("ConfigurationUpdate", async(channel, message) =>
            {
                if (message.HasValue)
                {
                    _logger.LogInformation("in subscription.");
                    var result = await _redis.GetStringAsync <string>("Config");
                    _logger.LogInformation($"{result}");
                }
            });
        }