0
A
回答
2
当您使用的CacheManager的Add方法将其添加到缓存中你可以指定你的项目到期:
public void Add (
string key,
Object value,
CacheItemPriority scavengingPriority,
ICacheItemRefreshAction refreshAction,
params ICacheItemExpiration[] expirations
)
在这固然牵强例如,如果产品价格低于100,那么产品将被缓存24小时,否则它将在缓存的上次访问时间后1分钟到期。
Product[] products = GetProducts();
CacheManager cache = CacheFactory.GetCacheManager();
AbsoluteTime twentyFourHoursLater = new AbsoluteTime(DateTime.Now.AddHours(24));
SlidingTime oneMinuteSlidingTime = new SlidingTime(TimeSpan.FromMinutes(1));
foreach (Product product in products)
{
if (product.ProductPrice < 100)
{
cache.Add(product.ProductID, product, CacheItemPriority.Normal, null,
twentyFourHoursLater);
}
else
{
cache.Add(product.ProductID, product, CacheItemPriority.Normal, null,
oneMinuteSlidingTime);
}
}
相关问题
- 1. 扩展企业库缓存块 - 如何获取MyCacheManager的实例?
- 2. 监视企业库缓存
- 3. 在asp.net中使用企业库缓存应用程序块mvc2
- 4. c#企业库CacheManager的缓存性能
- 5. 企业库缓存中的高速缓存管理器应用程序块
- 6. 在Visual Studio中设置“企业”项目的最佳实践?
- 7. 缓存过期事件asp.net企业库
- 8. 禁用企业库高速缓存应用程序块
- 9. 使用企业缓存块立即刷新整个缓存
- 10. 企业中企业实体验证的首选方法
- 11. PHP设置cookie的寿命
- 12. 针对企业的Windows内存缓存
- 13. 如何设置Hibernate的二级缓存的寿命只是一个实体上Wildfly(Infinispan的)
- 14. 企业库5.0日志块在asp.net中?
- 15. 企业库数据访问块事务管理最佳实践
- 16. 企业库验证块
- 17. 企业库验证块
- 18. 企业库安全模块
- 19. 企业MVC应用项目设置与实体框架
- 20. 设置命令企业库4.1数据访问超时?
- 21. Microsoft企业库缓存应用程序块不是线程安全的?
- 22. 在代码中配置企业库
- 23. 缓存控制:最大年龄设置
- 24. 将企业库的验证块与实体框架一起使用
- 25. SharePoint企业Wiki设置
- 26. SAS企业指南设置
- 27. 企业库中的事务
- 28. 用最大大小的缓存文件夹实现PHP缓存
- 29. 企业缓存应用程序块| IsolatedStorage和Scavenging
- 30. 在ASP.NET缓存中缓存EF实体
谢谢。确实有点牵强,但说明性:) – 2009-10-06 14:57:13