public void Put_should_retry_until_generation_matches_the_server() { // Arrange var cache = new RedisCache("region", this.ClientManager); // Another client incremented the generation. Redis.Increment(cache.CacheNamespace.GetGenerationKey(), 100); // Act cache.Put(999, new Person("Foo", 10)); // Assert Assert.Equal(cache.CacheNamespace.GetGeneration(), 101); var data = RedisNative.Get(cache.CacheNamespace.GlobalCacheKey(999)); var person = (Person)serializer.Deserialize(data); Assert.Equal("Foo", person.Name); Assert.Equal(10, person.Age); }
public void Put_should_serialize_item_and_set_with_expiry() { // Arrange var cache = new RedisCache("region", this.ClientManager); // Act cache.Put(999, new Person("Foo", 10)); // Assert var cacheKey = cache.CacheNamespace.GlobalCacheKey(999); var data = RedisNative.Get(cacheKey); var expiry = Redis.GetTimeToLive(cacheKey); Assert.True(expiry >= TimeSpan.FromMinutes(4) && expiry <= TimeSpan.FromMinutes(5)); var person = serializer.Deserialize(data) as Person; Assert.NotNull(person); Assert.Equal("Foo", person.Name); Assert.Equal(10, person.Age); }