Example #1
0
        public async Task AddOrUpdate(CountryCacheModel model)
        {
            try
            {
                var countries = await LoadFromRedis();

                var country = countries.FirstOrDefault(c => c.Id == model.Id);
                if (country == null)
                {
                    countries.Add(model);
                }
                else
                {
                    country.Name = model.Name;
                }

                await DistributedCache.Set(_cacheKey,
                                           countries);
            }
            catch (Exception exception)
            {
                _logger.Info(exception.ToString);
            }
        }
Example #2
0
 public CountryModel(CountryCacheModel model)
 {
     Id   = model.Id;
     Name = model.Name;
 }