コード例 #1
0
        public RedisIntegrationTest()
        {
            _testObject           = new CachingTestClass();
            _serializedTestObject = KrakenSerializer.Serialize(_testObject);

            _redisRetryPolicy = new RedisRetryPolicy(50, 100, 150);
            _connection       = new RedisConnection(RedisConnectionString, _redisRetryPolicy);
        }
コード例 #2
0
        public SquirrelCacheTest()
        {
            _config.AbsoluteExpiration = TimeSpan.FromSeconds(5);
            _config.MaximumMemorySize  = 1000;
            _config.TimerInterval      = TimeSpan.FromSeconds(1);

            _cacheRepository      = new SquirrelCache(_config, _noCloningProvider, _serializationProvider);
            _testObject           = new CachingTestClass();
            _serializedTestObject = KrakenSerializer.Serialize(_testObject);
        }
コード例 #3
0
        public void ObjectShouldBeReplaced()
        {
            var bigTestObject = new CachingTestClass()
            {
                ByteArray = new bool[800]
            };
            var bigSerializedTestObject = KrakenSerializer.Serialize(bigTestObject);

            var key = Guid.NewGuid().ToString();

            _cacheRepository.Set(key, _serializedTestObject);
            WaitFor(0.5);
            Assert.Equal(_serializedTestObject.Length, _cacheRepository.EstimatedMemorySize);
            _cacheRepository.Set(key, bigSerializedTestObject);

            WaitFor(0.5);
            Assert.Equal(bigSerializedTestObject.Length, _cacheRepository.EstimatedMemorySize);
            Assert.Equal(1, _cacheRepository.NumberOfObjects);
        }
コード例 #4
0
        public void ObjectShouldBeRemovedFromTheCacheBecauseTheCacheIsOverTheConfiguredMemoryLimit()
        {
            var bigTestObject = new CachingTestClass()
            {
                ByteArray = new bool[1000]
            };
            var bigSerializedTestObject = KrakenSerializer.Serialize(bigTestObject);

            var key = Guid.NewGuid().ToString();

            _cacheRepository.Set(key, bigSerializedTestObject);

            Assert.True(_cacheRepository.EstimatedMemorySize > _config.MaximumMemorySize);

            WaitFor(_config.TimerInterval.TotalSeconds * 2);

            Assert.Equal(0, _cacheRepository.EstimatedMemorySize);
            Assert.Equal(0, _cacheRepository.NumberOfObjects);
        }
コード例 #5
0
        public void ObjectsShouldBeRemovedInTheOrderTheyWereAddedOnceTheCacheisOverTheConfiguredMemoryLimit()
        {
            var bigTestObject = new CachingTestClass()
            {
                ByteArray = new bool[800]
            };
            var bigSerializedTestObject = KrakenSerializer.Serialize(bigTestObject);

            var key1 = Guid.NewGuid().ToString();
            var key2 = Guid.NewGuid().ToString();

            _cacheRepository.Set(key1, _serializedTestObject);
            _cacheRepository.Set(key2, bigSerializedTestObject);

            Assert.True(_cacheRepository.EstimatedMemorySize > _config.MaximumMemorySize);

            WaitFor(_config.TimerInterval.TotalSeconds * 2);

            Assert.Equal(bigSerializedTestObject.Length, _cacheRepository.EstimatedMemorySize);
            Assert.Equal(1, _cacheRepository.NumberOfObjects);
            Assert.True(_cacheRepository.Get <CachingTestClass>(key2).IsSuccessful);
            Assert.NotNull(_cacheRepository.Get <CachingTestClass>(key2).Value);
        }
コード例 #6
0
 public NonSerializableCacheTest()
 {
     _testObject = new CachingTestClass();
 }