コード例 #1
0
        //Redis
        public static void RedisCaching(int[] numForFibbonachi)
        {
            var redisCache = new RedisProvider();

            for (int i = 0; i < numForFibbonachi.Length; i++)
            {
                Console.WriteLine("For item {0} Fibonacci sequence is:", numForFibbonachi[i]);
                var sequenceFromCache = redisCache.GetFromRedis <int>(numForFibbonachi[i].ToString());
                if (sequenceFromCache != null)
                {
                    Console.WriteLine("value from Cache");
                    WriteResult(sequenceFromCache);
                }
                else
                {
                    var sequence = GetFibonacciSequence(numForFibbonachi[i]);
                    redisCache.AddToRedis(numForFibbonachi[i].ToString(), sequence);
                    WriteResult(sequence);
                }
            }
        }