WebApp.Services.AddressService.CachedCityList C# (CSharp) Method

CachedCityList() public method

public CachedCityList ( ) : List
return List
        public List<City> CachedCityList()
        {
            List<City> list;
            if (!Cache.TryGetValue(CacheKeys.City, out list))
            {
                list = DbContext.Cities.OrderBy(x => x.Name).ToList();

                Cache.Set(CacheKeys.City, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(5)));
                _logger.LogInformation($"{CacheKeys.City} updated from source.");
            }

            return list;
        }