Esempio n. 1
0
        private async Task <AppraisalQuoteResponse> GetFromCache(AppraisalQuote request)
        {
            AppraisalQuoteResponse result;

            using (var client = new RedisClient(ConfigUtils.GetAppSetting("RedisEndpoint").ToRedisEndpoint()))
            {
                result = client.As <AppraisalQuoteResponse>().GetValue("JLR-" + request.StateCode + "-appraisalPrices");
                if (result == null)
                {
                    result = await AppraisalDataLookup.GetQuoteForState(request);

                    client.Set("JLR-" + request.StateCode + "-appraisalPrices", result, DateTime.Now.AddHours(1));
                }
            }

            return(result);
        }
Esempio n. 2
0
        public async Task <AppraisalQuoteResponse> Get(AppraisalQuote request)
        {
            AppraisalQuoteResponse result;
            var watch = System.Diagnostics.Stopwatch.StartNew();

            if (request.FromCache)
            {
                result = await GetFromCache(request);
            }
            else
            {
                result = await AppraisalDataLookup.GetQuoteForState(request);
            }

            Log.InfoFormat("Call returning from {0} in {1} milliseconds", request.FromCache ? "cache" : "db", watch.ElapsedMilliseconds);
            return(result);
        }