本文整理汇总了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);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}