KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I found myself into a CacheItem that didn't clean up correctly. While looking at MSDN and correct myself into using Utc-based calculation, I found this confusing information: CacheItemPolicy.Priority CacheItemPolicy.AbsoluteExpiration AbsolutExpiration is used to set a "keep-alive" of a CacheItem , Priority.NotRemovable is used to force CacheItem to exist forever. No notification about what property overrides the other. The code below do compile and SQL Profiler also confirm that the database is queried only once, while every other request came from cache. CacheItemPolicy _cachePolicy = new CacheItemPolicy() { AbsoluteExpiration = new DateTimeOffset(DateTime.Now.AddHours(6)), Priority = CacheItemPriority.NotRemovable }; I assume that this code force the cache items to stay forever but are cleared after 12 hours from creation, in line with the MSDN's note about the setting. "Cache implementations should set the NotRemovable priority for a cache entry only if the cache implementation provides ways to evict entries from the cache and to manage the number of cache entries" Then the other side, why would both properties work together at all? Does the implementation bring some kind of "more non-removable"?
Tags (comma-separated)
Save Edits
Cancel