Ejemplo n.º 1
0
        public void GetPerformance(int iterations)
        {
            // Given

            const string key   = "GetPerformance_Key";
            const string value = "GetPerformance_Value";

            _cache.Set(key, value);
            _cache.Get(key);

            // When

            var stopwatch = new Stopwatch();

            for (var i = 0; i < iterations; ++i)
            {
                stopwatch.Start();

                _cache.Get(key);

                stopwatch.Stop();
            }

            // Then
            var avg = stopwatch.Elapsed.TotalMilliseconds / iterations;

            Console.WriteLine(@"RedisCacheImpl.Get()");
            Console.WriteLine(@"  Iteration count: {0}", iterations);
            Console.WriteLine(@"  Operation time : {0:N4} sec", avg);
            Console.WriteLine(@"  Operation/sec  : {0:N4}", 1000 / avg);
        }
Ejemplo n.º 2
0
 public void ShouldThrowExceptionWhenKeyIsNullOrEmpty(string key)
 {
     Assert.Throws <ArgumentNullException>(() => _cache.Contains(key));
     Assert.Throws <ArgumentNullException>(() => _cache.Get(key));
     Assert.Throws <ArgumentNullException>(() => _cache.Set(key, "value"));
     Assert.Throws <ArgumentNullException>(() => _cache.Remove(key));
 }
Ejemplo n.º 3
0
        private IDictionary <string, string> GetCachedData(RedisCacheImpl impl, string key)
        {
            var actualCacheData = impl.Get(key);

            if (actualCacheData != null)
            {
                var serializer = new Dev2JsonSerializer();
                return(serializer.Deserialize <IDictionary <string, string> >(actualCacheData));
            }
            return(null);
        }
Ejemplo n.º 4
0
        private List <SpecAssignValue> GetCachedData(RedisCacheImpl impl, string key)
        {
            var activities      = new List <SpecAssignValue>();
            var actualCacheData = impl.Get(key);

            if (actualCacheData != null)
            {
                var serializer = new Dev2JsonSerializer();
                var actualData = serializer.Deserialize <IDictionary <string, string> >(actualCacheData);

                foreach (var item in actualData)
                {
                    activities.Add(new SpecAssignValue {
                        Name = item.Key, Value = item.Value
                    });
                }
            }
            return(activities);
        }