コード例 #1
0
ファイル: CityController.cs プロジェクト: glebvk85/MQ
        public LocationsResponse GetLocations(string city = "")
        {
            var    cacheProvider = new MemCacheProvider <LocationsResponse>();
            string cacheKey      = $"city;{city}";
            var    response      = cacheProvider.TryGetResponse(cacheKey);

            if (response == null)
            {
                var service = new SearchService();
                response = service.FindByCity(city);
                cacheProvider.SaveResponse(cacheKey, response);
            }

            return(response);
        }
コード例 #2
0
        public IPResponse GetLocation(string ip = "")
        {
            var    cacheProvider = new MemCacheProvider <IPResponse>();
            string cacheKey      = $"ip;{ip}";
            var    response      = cacheProvider.TryGetResponse(cacheKey);

            if (response == null)
            {
                var service = new SearchService();
                response = service.FindByIp(ip);
                cacheProvider.SaveResponse(cacheKey, response);
            }

            return(response);
        }