Upload
fwdays
View
364
Download
1
Embed Size (px)
Citation preview
Data access latency
Register L1 L2 L3 RAM SSD HDD0
200
400
600
800
1000
1200Latency
Latency
Common caching scenarios
• Static content delivery• Increase database IO bandwidth• Slow API integration
Caching Practices
• InProc data caching• Dedicated cache service• Static content cache• Distributed cache
Distributed Cache topologies
Alachisoft
Aspects oriented programming
Programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns. It does so by adding additional behavior to existing code without modifying the code itself
Concern areas• Security• Logging• Metrics profiling• Dependency Injection• Caching
AOP in common IoC frameworks
Application Proxy Service
public interface IInterceptor
void Intercept(IInvocation invocation);
bool CanIntercept(IInvocation invocation);
public interface IInvocation
MethodInfo Method { get; set; }
object Target { get; set; }
object Result { get; set; }
Service definition with a cache support[Cache]
public interface ISomeThirdPartyDataProvider
{
[Cache(CacheScope.Session, Timeout=200, Key=“SD”)]
UserSubscriptionDetails [] GetSubscriptions(User u);
[Cache(CacheScope.Global, Timeout = -1)]
AreaLocationDetails [] GetLocationDetails([Key] Area a);
[Cache(CacheScope.Session, Key=“userProducts”,
Invalidate = typeof(AvailableProductsInvalidationStrategy))]
Product [] GetAvailableProducts ()
}
Caching interceptor internalssealed class CacheInterceptor : IInterceptor
{
public void Intercept(IInvocation invocation)
{
var cacheOptions = invocation.Method.GetAttribute();
var cache = IoC.Resolve<ICache>();
if (!cache.TryGetValue(cacheOptions.CacheKey, out value))
invocation.Result = cache[cacheOptions] = invocation.Proceed();
else
invocation.Result = value;
}
}
Pros & cons
• Strict separation of concern• Clean application code• Nonfunctional design specification inside a
declaration• Focus on features instead of infrastructure
• Increasing project learning curve• Little flexibility with a cached data invalidation
THANK YOU