Exemple #1
0
        public async Task <Product> findProduct(string id)
        {
            string  redisKey = $"Product_{id}";
            Product product  = null;
            string  result   = await redisHelper.GetOrAddString <Product>(redisKey, () =>
            {
                return(dapperHelper.GetProduct(id));
            }, 60);

            if (!string.IsNullOrWhiteSpace(result))
            {
                product = JsonConvert.DeserializeObject <Product>(result);
            }
            return(await Task.FromResult(product));
        }