net distributed caching
DESCRIPTION
A deck on distributed caching, using a open source framework (cachesharp) I developed for .net.TRANSCRIPT
.Net Distributed Caching
Paul Fryer
Software Architect, Fiserv
About Me
Portland Hipster
WHAT IS CACHE?
cache /kaSH/
verb
–Store away in hiding or for future use.
Use of phrase “caching” in books, last 200 years
WHAT IS A DISTRIBUTED CACHE?
Horizontal Scale
Online search interest for various cache providers
HOW TO CACHE
Pattern: Read Through Cache
Cache Scopes
A = Application
T = Tenant
U = User
S = Session
Where to Cache
• Application / Tenant Data = Local Cache
• Session / User Data = Distributed Cache
Cache Key Pattern
{Scope}.{Identity}.{Uniqueness}
A.WebUI.DefaultThemeA.WebUI.Exchanges.Page1.PageSize10
T.TenantB.MaxHistoryT.TenantC.ContactInformation
U.johnB22.ProfileIconU.sallyP1.LastPost
S.2928328387.RequiresSecondFactorAuthenticationS.2050988830.TransactionHistory.Page2.PageSize20
Time to Live
• How critical is the data?
– How current does it have to be?
• Is eventual consistency ok?
TTL Performance Relationship
Time to live
Perf
orm
ance
Consistency
• Events that invalidate cached data should cause the cached data to update or remove if possible.
• You often only able to capture events within your application.
• Underlying changes to the source can cause cached data to be out of sync. Mitigate this with appropriate TTL.
• Pub/Sub capabilities exist on some distributed caches.
Code Examples
• Adding a read through cache pattern to a slow service.
• Consolidating the caching behavior into a reusable attribute.
• Using a distributed cache to track statistics about connections, like number or requests per second.
• Performance testing.
Resources
• CacheSharp – abstraction layer that maps into multiple cache providers. Useful for establishing baselines and comparing different providers.
• Redis Session State Provider – ASP.Net web application session state provider. Useful for web apps that want to move session state out of process.
• CacheCow – HTTP Caching framework. Useful for implementing HTTP caching in web applications.
Connect
• My Blog