public void SimpleTest() { var cache = new HashtableTemplateCache(3); Assert.IsNull(cache.Get("anything")); cache.Clear(); cache.Add("key1", new ParseList()); cache.Add("key2", new ParseList()); cache.Add("key3", new ParseList()); Assert.IsNotNull(cache.Get("key1")); Assert.IsNotNull(cache.Get("key2")); Assert.IsNotNull(cache.Get("key3")); cache.Add("key4", new ParseList()); object key1Object = cache.Get("key1"); Assert.IsNull(key1Object); }
public void StressHashtableCache() { int maxItems = 1000000; int maxHits = 1000000; Random random = new Random(); var cache = new HashtableTemplateCache(maxItems); cache.Clear(); for (int i =0;i < maxItems; i++) cache.Add("key" + i, new ParseList()); for( int i=0; i < maxHits; i++) { cache.Get("key" + random.Next(maxItems)); } }