public void Test_GetFromFallback_Ok_Saved() { // Arrange var usingKey = this.KeyBuilder.UseKey( nameof(Test_GetFromFallback_Ok_Saved) ); var expected = Guid.NewGuid().ToString(); var expiry = TimeSpan.FromMinutes(1); var memoryStorage = new MemoryStorage(expiry); var redisStorage = this.GetRedisStorage(expiry) .Delete(usingKey) .Add(usingKey, expected); var cacheManager = new StorageManager(FallbackPolicy.SaveFromFallback) .SetDefault(memoryStorage) .AddFallback(redisStorage); // Actual var actual = cacheManager.Get(usingKey); // Assert Assert.AreEqual(expected, actual); Assert.AreEqual( expected, cacheManager.DefaultStorage.Get(usingKey) ); }
public void Test_KeyWithSpace_GetOk() { var memoryStorage = new MemoryStorage(TimeSpan.FromSeconds(10)); var redisStorage = this.GetRedisStorage(TimeSpan.FromSeconds(10)); this.Test_KeyWithSpace_GetOk( new StorageManager() .SetDefault(memoryStorage) .AddFallback(redisStorage) ); }
public void Test_ItemDelete_CannotGet() { var memoryStorage = new MemoryStorage(TimeSpan.FromSeconds(10)); var redisStorage = this.GetRedisStorage(TimeSpan.FromSeconds(10)); this.Test_ItemDelete_CannotGet( this.KeyBuilder.UseKey(nameof(Test_ItemDelete_CannotGet)), new StorageManager() .SetDefault(memoryStorage) .AddFallback(redisStorage) ); }
public void Test_GetOrAdd_Success() { var memoryStorage = new MemoryStorage(TimeSpan.FromSeconds(10)); var redisStorage = this.GetRedisStorage(TimeSpan.FromSeconds(10)); this.Test_GetOrAdd_Success( this.KeyBuilder.UseKey(nameof(Test_GetOrAdd_Success)), new StorageManager() .SetDefault(memoryStorage) .AddFallback(redisStorage), Guid.NewGuid().ToString() ); }
public void Test_ItemExpired_ReturnNull() { var expiry = TimeSpan.FromMilliseconds(100); var memoryStorage = new MemoryStorage(expiry); var redisStorage = this.GetRedisStorage(expiry); this.Test_ItemExpired_ReturnNull( this.KeyBuilder.UseKey(nameof(Test_ItemExpired_ReturnNull)), new StorageManager() .SetDefault(memoryStorage) .AddFallback(redisStorage), expiry ); }