public void EvictionLimitIsReached() { _client.ConfigEviction(CollectionName, EvictionType.LessRecentlyUsed, 100, 10, 0); var desc = _client.GetServerDescription(); Assert.IsNotNull(desc); Assert.AreEqual(desc.DataStoreInfoByFullName.Count, 1); var info = desc.DataStoreInfoByFullName[CollectionName]; Assert.IsNotNull(info); Assert.AreEqual(info.EvictionPolicy, EvictionType.LessRecentlyUsed); //add one item var item1 = new CacheableTypeOk(1, 1001, "aaa", new DateTime(2010, 10, 10), 1500); _client.PutOne(item1); //reload the item by primary key var item1Reloaded = _client.GetOne <CacheableTypeOk>(i => i.PrimaryKey == 1); Assert.AreEqual(item1, item1Reloaded); //add 100 items; eviction should be triggered(10 items should be removed) for (var i = 0; i < 100; i++) { var item = new CacheableTypeOk(i + 2, i + 1002, "aaa", new DateTime(2010, 10, 10), 1500); _client.PutOne(item); } //reload all items IList <CacheableTypeOk> itemsInAaa = _client.GetMany <CacheableTypeOk>(i => i.IndexKeyFolder == "aaa").ToList(); Assert.AreEqual(91, itemsInAaa.Count); //eviction triggered at 100 removed 10 added 1 var itemsAsList = new List <CacheableTypeOk>(itemsInAaa); itemsAsList.Sort((x, y) => x.PrimaryKey.CompareTo(y.PrimaryKey)); //check that the first 10 items were evicted Assert.IsTrue(itemsAsList[0].PrimaryKey == 11); //update the first item. This should prevent it from being evicted _client.PutOne(new CacheableTypeOk(11, 1001, "aaa", new DateTime(2010, 10, 10), 1500)); for (var i = 0; i < 10; i++) { var item = new CacheableTypeOk(i + 102, i + 1102, "aaa", new DateTime(2010, 10, 10), 1500); _client.PutOne(item); } itemsInAaa = _client.GetMany <CacheableTypeOk>(i => i.IndexKeyFolder == "aaa").ToList(); Assert.AreEqual(itemsInAaa.Count, 91); //(100 - 10 +1) itemsAsList = new List <CacheableTypeOk>(itemsInAaa); itemsAsList.Sort((x, y) => x.PrimaryKey.CompareTo(y.PrimaryKey)); //check that the item having 11 as primary key was not evicted Assert.AreEqual(11, itemsAsList[0].PrimaryKey); Assert.AreEqual(22, itemsAsList[1].PrimaryKey); }