Ejemplo n.º 1
0
        private async Task <FeeScheduleQuoteResponse> GetFromCache(FeeScheduleQuote request)
        {
            FeeScheduleQuoteResponse result;

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

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

            return(result);
        }
Ejemplo n.º 2
0
        public async Task <FeeScheduleQuoteResponse> Get(FeeScheduleQuote request)
        {
            FeeScheduleQuoteResponse result;
            var watch = System.Diagnostics.Stopwatch.StartNew();

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

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