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


C# Cache.SaveMappingsAndCheckLimits方法代码示例

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


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

示例1: Initialize

        public async void Initialize()
        {
            var cacheContainer = new CacheContainer();
            cacheContainer.Register<ILogger, TestLogger>();
            cacheContainer.Register<IVersionProvider, TestVersionProvider>().WithValue("version", new Version("1.0"));
            cacheContainer.Register<IStorage, TestStorage>();
            cacheContainer.Register<ISerializer, ProtoBufSerializer>().WithDependency("storage", typeof(IStorage).FullName).WithValue("userTypes", null);

            var cacheConfiguration = new CacheConfiguration(900, 6, 800, 5);

            _cache = new Cache(cacheContainer, cacheConfiguration);
            await _cache.Initialize();
            await _cache.Set("stringKey1", "stringValue1");
            Thread.Sleep(20);
            await _cache.Set("stringKey2", "stringValue2");
            Thread.Sleep(20);
            await _cache.Set("byteKey3", new byte[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24});
            Thread.Sleep(20);
            await _cache.Set("stringKey4", "stringValue4");
            Thread.Sleep(20);
            await _cache.Set("Int32Key", 42);
            Thread.Sleep(20);
            await _cache.Set("DateTimeKey", _dateTime);
            Thread.Sleep(20);
            await _cache.Set("floatKey", 13.37f);
            Thread.Sleep(20);
            await _cache.Set("decimalKey", 13.37m);

            await _cache.SaveMappingsAndCheckLimits(null);
        }
开发者ID:IvanLeonenko,项目名称:windows-cache,代码行数:30,代码来源:When_overall_and_in_memory_size_and_quantity_limits_exceeded.cs

示例2: Initialize

        public async void Initialize()
        {
            var cacheContainer = new CacheContainer();
            cacheContainer.Register<ILogger, TestLogger>();
            cacheContainer.Register<IVersionProvider, TestVersionProvider>().WithValue("version", new Version("1.0"));
            cacheContainer.Register<IStorage, TestStorage>();
            cacheContainer.Register<ISerializer, ProtoBufSerializer>().WithDependency("storage", typeof(IStorage).FullName).WithValue("userTypes", null);

            var cacheConfiguration = new CacheConfiguration(2048, 6, 2048, 5);

            _cache = new Cache(cacheContainer, cacheConfiguration);
            await _cache.Initialize();
            await _cache.Set("stringKey1", "stringValue1");
            await _cache.Set("stringKey2", "stringValue2");
            await _cache.Set("stringKey3", "stringValue3");
            await _cache.Set("someBytes", new byte[] { 12, 32, 43 });
            await _cache.Set("Int32Key1", 1);
            await _cache.Set("dateTimeKey1", _dateTime);
            await _cache.SaveMappingsAndCheckLimits(null);
        }
开发者ID:IvanLeonenko,项目名称:windows-cache,代码行数:20,代码来源:When_in_memory_quantity_limit_exceeded.cs

示例3: Initialize

        public async void Initialize()
        {
            var cacheContainer = new CacheContainer();
            cacheContainer.Register<ILogger, TestLogger>();
            cacheContainer.Register<IVersionProvider, TestVersionProvider>().WithValue("version", new Version("1.0"));
            cacheContainer.Register<IStorage, TestStorage>();
            cacheContainer.Register<ISerializer, ProtoBufSerializer>().WithDependency("storage", typeof(IStorage).FullName).WithValue("userTypes", null);

            var cacheConfiguration = new CacheConfiguration(500, 10, 500, 5);

            _cache = new Cache(cacheContainer, cacheConfiguration);
            await _cache.Initialize();
            await _cache.Set("stringKey1", "stringValue1");
            Thread.Sleep(20);
            await _cache.Set("stringKey2", "stringValue2");
            Thread.Sleep(20);
            await _cache.Set("stringKey3", "stringValue3");
            Thread.Sleep(20);
            await _cache.Set("stringKey4", "stringValue4");
            Thread.Sleep(20);
            await _cache.Set("Int32Key", 42);
            await _cache.SaveMappingsAndCheckLimits(null);
        }
开发者ID:IvanLeonenko,项目名称:windows-cache,代码行数:23,代码来源:When_overall_and_in_memory_size_limits_exceeded.cs


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