Skip to content

Instantly share code, notes, and snippets.

@asimmon
Created November 20, 2015 15:52
Show Gist options
  • Save asimmon/5587eb89abd266f9dadf to your computer and use it in GitHub Desktop.
Save asimmon/5587eb89abd266f9dadf to your computer and use it in GitHub Desktop.
Caching method results with AOP - Autofac Configuration
public class MyModule : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<MemoryCacheProvider>()
.As<ICacheProvider>()
.SingleInstance();
builder.RegisterType<CacheResultInterceptor>()
.SingleInstance();
builder.RegisterType<FakeExpensiveClass>()
.As<IDoExpensiveWork>()
.EnableInterfaceInterceptors()
.InterceptedBy(typeof(CacheResultInterceptor))
.SingleInstance();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment