当前位置: 首页>>代码示例>>C#>>正文


C# LruCache.Put方法代码示例

本文整理汇总了C#中LruCache.Put方法的典型用法代码示例。如果您正苦于以下问题:C# LruCache.Put方法的具体用法?C# LruCache.Put怎么用?C# LruCache.Put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LruCache的用法示例。


在下文中一共展示了LruCache.Put方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LruCache_Get

 public void LruCache_Get()
 {
     LruCache<int, string> cache = new LruCache<int, string>(2);
     cache.Put(1, "One");
     cache.Put(2, "Two");
     Assert.IsNotNull(cache.Get(1));
     Assert.IsNotNull(cache.Get(2));
 }
开发者ID:ralf-lindberg-3bits,项目名称:blackbox,代码行数:8,代码来源:LruCacheTests.cs

示例2: LruCache_Contains

 public void LruCache_Contains()
 {
     LruCache<int, string> cache = new LruCache<int, string>(2);
     cache.Put(1, "One");
     cache.Put(2, "Two");
     Assert.IsTrue(cache.Contains(1));
     Assert.IsTrue(cache.Contains(2));
     Assert.IsFalse(cache.Contains(3));
 }
开发者ID:ralf-lindberg-3bits,项目名称:blackbox,代码行数:9,代码来源:LruCacheTests.cs

示例3: LruCache_Clear

 public void LruCache_Clear()
 {
     LruCache<int, string> cache = new LruCache<int, string>(2);
     cache.Put(1, "One");
     cache.Put(2, "Two");
     Assert.AreEqual(2, cache.Count);
     cache.Clear();
     Assert.AreEqual(0, cache.Count);
 }
开发者ID:ralf-lindberg-3bits,项目名称:blackbox,代码行数:9,代码来源:LruCacheTests.cs

示例4: LruCache_LeastUsedObjectIsRemovedWhenCapacityIsReached

 public void LruCache_LeastUsedObjectIsRemovedWhenCapacityIsReached()
 {
     LruCache<int, string> cache = new LruCache<int, string>(2);
     cache.Put(1, "One");
     cache.Put(2, "Two");
     Assert.IsNotNull(cache.Get(1));
     Assert.IsNotNull(cache.Get(2));
     Assert.AreEqual(2, cache.Count);
     cache.Put(3, "Three");
     Assert.AreEqual(2, cache.Count);
     Assert.IsNull(cache.Get(1));
     Assert.IsNotNull(cache.Get(2));
     Assert.IsNotNull(cache.Get(3));
     cache.Put(4, "Four");
     Assert.AreEqual(2, cache.Count);
     Assert.IsNull(cache.Get(2));
     Assert.IsNotNull(cache.Get(3));
     Assert.IsNotNull(cache.Get(4));
 }
开发者ID:ralf-lindberg-3bits,项目名称:blackbox,代码行数:19,代码来源:LruCacheTests.cs

示例5: LruCache

 public void GetとPutがスレッドセーフである()
 {
     LruCache lruCache = new LruCache(5, 1);
     Action action1 = () => {
         for (int i = 0; i < 1000 * 1000; i++)
         {
             lruCache.Put("a", "abc");
             Assert.AreEqual("abc", lruCache.Get("a"));
         }
     };
     Action action2 = () => {
         for (int i = 0; i < 1000 * 1000; i++)
         {
             lruCache.Put("a", "abc");
             Assert.AreEqual("abc", lruCache.Get("a"));
         }
     };
     action1.BeginInvoke(null, null);
     action2.BeginInvoke(null, null);
 }
开发者ID:kaorun55,项目名称:TddBootCamp,代码行数:20,代码来源:LruCacheTest.cs

示例6: LruCache_MakeSureItemRemovedEventIsCalledWhenCacheIsDisposed

 public void LruCache_MakeSureItemRemovedEventIsCalledWhenCacheIsDisposed()
 {
     LruCache<int, string> cache = new LruCache<int, string>(2);
     List<string> removedList = new List<string>();
     cache.ItemRemoved += (o, s) => { removedList.Add(s.Item); };
     cache.Put(1, "One");
     cache.Put(2, "Two");
     Assert.AreEqual(0, removedList.Count);
     cache.Dispose();
     Assert.AreEqual(2, removedList.Count);
     Assert.AreEqual("One", removedList[0]);
     Assert.AreEqual("Two", removedList[1]);
 }
开发者ID:ralf-lindberg-3bits,项目名称:blackbox,代码行数:13,代码来源:LruCacheTests.cs


注:本文中的LruCache.Put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。