public RedisIntegrationTest() { _testObject = new CachingTestClass(); _serializedTestObject = KrakenSerializer.Serialize(_testObject); _redisRetryPolicy = new RedisRetryPolicy(50, 100, 150); _connection = new RedisConnection(RedisConnectionString, _redisRetryPolicy); }
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); }
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); }
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); }
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); }
public NonSerializableCacheTest() { _testObject = new CachingTestClass(); }