コード例 #1
0
        public async Task <IActionResult> Get(string key)
        {
            try
            {
                var item = await _redisService.Consume(key);

                return(Ok(item));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(StatusCode(409));
            }
        }
コード例 #2
0
        public async Task <double> GetCurrencyByKey(string key)
        {
            if (key == null)
            {
                return(1);
            }
            var str = await _redisService.Consume("currency");

            var currenciesString = str.Value;
            var currenciesModel  = ParseCurrenciesToModel(currenciesString);
            var nums             = currenciesModel.Where(z => z.cc == key).Select(x => x.rate);

            return(nums.Any() ? nums.First() : 1);
        }