Controlling Items in The Solution Cache: Elton Stoneman
Controlling Items in The Solution Cache: Elton Stoneman
Elton Stoneman
[email protected]
Outline
[Cache(CacheType=CacheType.Disk)]
public virtual IEnumerable<Make> GetMakes()
Vehicle Makes
Vehicle Makes
Demo
Adding items to the cache
Cache
A A
1 1
X X
Removing items from the cache
Cache
A A
X
Removing items from the cache
Cache
A A
X
Removing items from the cache
Cache
A A
1 1
X X
Removing items from the cache
Cache
A A
X X
Removing items from the cache
Not generic
May not control object updates
Different triggers and trigger types
Limited support in cache stores
Overhead
Multiple items cached per-method
By exception
Manual implementation
Cost to build
Removing items from the cache
Automatically – expiration
Sliding and absolute
Sliding
Set with timespan
Item removed if not accessed
Useful for keeping cache fresh
Not universally supported
Absolute
Set with expiry time
Item removed at expiry, accessed or not
Useful for keeping data fresh
Well supported
Expiry runs at cleanup interval
Removing items from the cache
Automatically – eviction
Some caches provide
Keeping the cache fresh
Within configured size
Remove items by policy
Least Recently Used
FIFO
Eviction runs at cleanup interval
Item removal transparent to consumers
App follows cache miss path
Removing items from the cache
Demo
Removing items from the cache
By absolute expiration
Cache target element
<sixeyed.core.caching>
<targets>
<target keyPrefix="ContentClient.GetItemsInternal"
cacheType="NCacheExpress"
seconds="20"/>
Demo
Disabling the cache
Globally
<sixeyed.core.caching enabled="false" />
Per-item
<sixeyed.core.caching>
<targets>
<target keyPrefix="ContentClient.GetItemsInternal"
cacheType="NCacheExpress"
seconds="20"
enabled="false"/>
Demo
Preloading the cache