Esempio n. 1
0
        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);
        }
Esempio n. 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);
        }