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


C# CacheTagHelper.GetMemoryCacheEntryOptions方法代码示例

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


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

示例1: UpdateCacheEntryOptions_SetsCachePreservationPriority

        public void UpdateCacheEntryOptions_SetsCachePreservationPriority()
        {
            // Arrange
            var priority = CacheItemPriority.High;
            var cache = new MemoryCache(new MemoryCacheOptions());
            var cacheTagHelper = new CacheTagHelper(cache)
            {
                Priority = priority
            };

            // Act
            var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(new EntryLink());

            // Assert
            Assert.Equal(priority, cacheEntryOptions.Priority);
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:16,代码来源:CacheTagHelperTest.cs

示例2: UpdateCacheEntryOptions_CopiesTriggersFromEntryLink

        public void UpdateCacheEntryOptions_CopiesTriggersFromEntryLink()
        {
            // Arrange
            var expiresSliding = TimeSpan.FromSeconds(30);
            var expected = new[] { Mock.Of<IExpirationTrigger>(), Mock.Of<IExpirationTrigger>() };
            var cache = new MemoryCache(new MemoryCacheOptions());
            var cacheTagHelper = new CacheTagHelper(cache)
            {
                ExpiresSliding = expiresSliding
            };

            var entryLink = new EntryLink();
            entryLink.AddExpirationTriggers(expected);

            // Act
            var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(entryLink);

            // Assert
            Assert.Equal(expected, cacheEntryOptions.Triggers.ToArray());
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:20,代码来源:CacheTagHelperTest.cs

示例3: UpdateCacheEntryOptions_SetsSlidingExpiration_IfExpiresSlidingIsSet

        public void UpdateCacheEntryOptions_SetsSlidingExpiration_IfExpiresSlidingIsSet()
        {
            // Arrange
            var expiresSliding = TimeSpan.FromSeconds(37);
            var cache = new MemoryCache(new MemoryCacheOptions());
            var cacheTagHelper = new CacheTagHelper(cache)
            {
                ExpiresSliding = expiresSliding
            };

            // Act
            var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(new EntryLink());

            // Assert
            Assert.Equal(expiresSliding, cacheEntryOptions.SlidingExpiration);
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:16,代码来源:CacheTagHelperTest.cs

示例4: UpdateCacheEntryOptions_SetsAbsoluteExpiration_IfExpiresAfterIsSet

        public void UpdateCacheEntryOptions_SetsAbsoluteExpiration_IfExpiresAfterIsSet()
        {
            // Arrange
            var expiresAfter = TimeSpan.FromSeconds(42);
            var cache = new MemoryCache(new MemoryCacheOptions());
            var cacheTagHelper = new CacheTagHelper(cache)
            {
                ExpiresAfter = expiresAfter
            };

            // Act
            var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(new EntryLink());

            // Assert
            Assert.Equal(expiresAfter, cacheEntryOptions.AbsoluteExpirationRelativeToNow);
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:16,代码来源:CacheTagHelperTest.cs

示例5: UpdateCacheEntryOptions_PrefersAbsoluteExpirationSpecifiedOnEntryLinkOverExpiresOn

        public void UpdateCacheEntryOptions_PrefersAbsoluteExpirationSpecifiedOnEntryLinkOverExpiresOn()
        {
            // Arrange
            var expiresOn1 = DateTimeOffset.UtcNow.AddDays(12);
            var expiresOn2 = DateTimeOffset.UtcNow.AddMinutes(4);
            var cache = new MemoryCache(new MemoryCacheOptions());
            var cacheTagHelper = new CacheTagHelper(cache)
            {
                ExpiresOn = expiresOn1
            };

            var entryLink = new EntryLink();
            entryLink.SetAbsoluteExpiration(expiresOn2);

            // Act
            var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(entryLink);

            // Assert
            Assert.Equal(expiresOn2, cacheEntryOptions.AbsoluteExpiration);
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:20,代码来源:CacheTagHelperTest.cs

示例6: UpdateCacheEntryOptions_UsesAbsoluteExpirationSpecifiedOnEntryLink

        public void UpdateCacheEntryOptions_UsesAbsoluteExpirationSpecifiedOnEntryLink()
        {
            // Arrange
            var expiresOn = DateTimeOffset.UtcNow.AddMinutes(7);
            var cache = new MemoryCache(new MemoryCacheOptions());
            var cacheTagHelper = new CacheTagHelper(cache)
            {
            };

            var entryLink = new EntryLink();
            entryLink.SetAbsoluteExpiration(expiresOn);

            // Act
            var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(entryLink);

            // Assert
            Assert.Equal(expiresOn, cacheEntryOptions.AbsoluteExpiration);
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:18,代码来源:CacheTagHelperTest.cs

示例7: UpdateCacheEntryOptions_SetsAbsoluteExpiration_IfExpiresOnIsSet

        public void UpdateCacheEntryOptions_SetsAbsoluteExpiration_IfExpiresOnIsSet()
        {
            // Arrange
            var expiresOn = DateTimeOffset.UtcNow.AddMinutes(4);
            var cache = new MemoryCache(new MemoryCacheOptions());
            var cacheTagHelper = new CacheTagHelper(cache)
            {
                ExpiresOn = expiresOn
            };

            // Act
            var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(new EntryLink());

            // Assert
            Assert.Equal(expiresOn, cacheEntryOptions.AbsoluteExpiration);
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:16,代码来源:CacheTagHelperTest.cs


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