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


C# LruCache类代码示例

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


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

示例1: Add_ItemIsAdded_ItemExistsInCache

        public void Add_ItemIsAdded_ItemExistsInCache()
        {
            var lru = new LruCache<string, string>(1);
            lru.Add("k1", "v1");

            Assert.IsTrue(lru.ContainsKey("k1"));
        }
开发者ID:youkebing,项目名称:dotnet-lru-cache,代码行数:7,代码来源:LruCacheTests.cs

示例2: 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

示例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_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

示例5: GetInitializedCache

 private static LruCache<string, string> GetInitializedCache(int max, params string[] entries)
 {
     var cache = new LruCache<string, string>(max);
     foreach (var entry in entries)
     {
         cache.Add(entry, entry);
     }
     return cache;
 }
开发者ID:jjnguy,项目名称:LRU.Net,代码行数:9,代码来源:UnitTest1.cs

示例6: QueueSystem

 private QueueSystem()
 {
     _howToDownload = new Dictionary<string, Func<Tile, Task<Tile>>>();
     _tilesBuffer = new QueueBuffer();
     _memoryCache = new LruCache<string, byte[]>(1000);
     _storageCache = new Dictionary<string, IOfflineStorage>();
     _executantPool = new ExecutantPool(6);
     RetryMaxCount = 5;
     _executantPool.DownloadImageCompleted += _executantPool_DownloadImageCompleted;
 }
开发者ID:SuperMap,项目名称:iClient-for-Win8,代码行数:10,代码来源:QueueSystem.cs

示例7: FilesController

 public FilesController(IElevationDataStorage elevationDataStorage,
     IHttpGatewayFactory httpGatewayFactory, 
     IDataContainerConverterService dataContainerConverterService,
     LruCache<string, TokenAndSecret> cache)
 {
     _elevationDataStorage = elevationDataStorage;
     _httpGatewayFactory = httpGatewayFactory;
     _dataContainerConverterService = dataContainerConverterService;
     _cache = cache;
 }
开发者ID:IsraelHikingMap,项目名称:Site,代码行数:10,代码来源:FilesController.cs

示例8: Add_MaxSizeIsReached_OldestItemDiscarded

        public void Add_MaxSizeIsReached_OldestItemDiscarded()
        {
            var lru = new LruCache<string, string>(5);
            lru.Add("k1", "v1");
            lru.Add("k2", "v2");
            lru.Add("k3", "v3");
            lru.Add("k4", "v4");
            lru.Add("k5", "v5");
            lru.Add("k6", "v6");

            Assert.IsFalse(lru.ContainsKey("k1"));
        }
开发者ID:youkebing,项目名称:dotnet-lru-cache,代码行数:12,代码来源:LruCacheTests.cs

示例9: Complex

        public void Complex()
        {
            var sut = new LruCache(3);
              var pages = new[] { 0, 1, 2, 3, 2, 3, 0, 4, 5, 2, 3, 1, 4, 3, 2, 6, 3, 2, 1, 2 };

              foreach (var page in pages)
            sut.AddPage(page);

              var result = sut.Pages;
              CollectionAssert.AreEqual(new[] { 2, 1, 3 }, result);
              Assert.AreEqual(14, sut.PageFaults);
        }
开发者ID:njmube,项目名称:public,代码行数:12,代码来源:LruCacheTests.cs

示例10: TestSizeIsLimited

        public void TestSizeIsLimited()
        {
            var cache = new LruCache<string, int>(10);

            for (int i = 0; i < 20; i++) {
                cache[i.ToString()] = i;
            }

            Assert.AreEqual(10, cache.Count);
            for (int i = 10; i < 20; i++) {
                Assert.IsTrue(cache.ContainsKey(i.ToString()));
            }
        }
开发者ID:purplecow,项目名称:media-library,代码行数:13,代码来源:TestCache.cs

示例11: TestLookup

        public void TestLookup()
        {
            var cache = new LruCache<int, string>(10);
            cache.InsertOrUpdate(1, "test");
            cache.InsertOrUpdate(2, "test");

            string retrieved;
            Assert.IsTrue(cache.TryLookup(1, out retrieved));
            Assert.AreEqual("test", retrieved);
            Assert.IsTrue(cache.TryLookup(2, out retrieved));
            Assert.AreEqual("test", retrieved);

            Assert.IsFalse(cache.TryLookup(3, out retrieved));
        }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:14,代码来源:GenericLruCacheTests.cs

示例12: OsmController

 public OsmController(IHttpGatewayFactory httpGatewayFactory,
     IDataContainerConverterService dataContainerConverterService,
     ICoordinatesConverter coordinatesConverter,
     IGpxSplitterService gpxSplitterService,
     IElasticSearchGateway elasticSearchGateway,
     LruCache<string, TokenAndSecret> cache)
 {
     _httpGatewayFactory = httpGatewayFactory;
     _dataContainerConverterService = dataContainerConverterService;
     _coordinatesConverter = coordinatesConverter;
     _gpxSplitterService = gpxSplitterService;
     _cache = cache;
     _elasticSearchGateway = elasticSearchGateway;
 }
开发者ID:IsraelHikingMap,项目名称:Site,代码行数:14,代码来源:OsmController.cs

示例13: Add_DuplicateKeyAdded_ThrowsArgumentException

 public void Add_DuplicateKeyAdded_ThrowsArgumentException()
 {
     try
     {
         var lru = new LruCache<string, string>(5);
         lru.Add("k1", "v1");
         lru.Add("k1", "v1");
         Assert.Fail("Should not have reached this point");
     }
     catch (ArgumentException)
     {
         Assert.Pass();
     }
 }
开发者ID:youkebing,项目名称:dotnet-lru-cache,代码行数:14,代码来源:LruCacheTests.cs

示例14: Add_ItemIsAdded_CurrentSizeIncreasesByItemSize

 public void Add_ItemIsAdded_CurrentSizeIncreasesByItemSize()
 {
     var lru = new LruCache<string, string>(1024, 2);
     Assert.AreEqual(0, lru.CurrentSize);
     lru.Add("k1", "v1");
     Assert.AreEqual(2, lru.CurrentSize);
     lru.Add("k2", "v2");
     Assert.AreEqual(4, lru.CurrentSize);
     lru.Add("k3", "v3");
     Assert.AreEqual(6, lru.CurrentSize);
     lru.Add("k4", "v4");
     Assert.AreEqual(8, lru.CurrentSize);
     lru.Add("k5", "v5");
 }
开发者ID:youkebing,项目名称:dotnet-lru-cache,代码行数:14,代码来源:LruCacheTests.cs

示例15: CacheAccessShouldBumpItToTheFront

        public void CacheAccessShouldBumpItToTheFront()
        {
            var cache = new LruCache<int, int>(3);

            cache[1] = 1;
            cache[2] = 2;
            cache[3] = 3;

            var a = cache[1];
            cache[4] = 4;

            Assert.AreEqual(cache[1], 1);
            Assert.AreEqual(cache[3], 3);
            Assert.AreEqual(cache[4], 4);
            Assert.IsFalse(cache.ContainsKey(2));
        }
开发者ID:purplecow,项目名称:media-library,代码行数:16,代码来源:TestCache.cs


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