Hi I am attempting to use Dynacache in my solution to cache data I am returning from Database so when I use Telerik grid to filter the data page etc I dont have to go back to the DB to get the data each time.
The example on the DynaCache page shows it being used with Ninject DI as below:
kernel.Bind<IDynaCacheService>().To<MemoryCacheService>();
kernel.Bind<ITestClass>().To(Cacheable.CreateType<TestClass>());
I am using SimpleInjector as my DI container. Has anyone used Dynacache with SimpleInjector as I am having some difficulty in getting the correct syntax to Register Dynacache with SimpleInjector the same way it is shown in Ninject
The Simple Injector equivalent is:
However, since
MemoryCacheService
is a framework type, you'd be better (as explained here) of making the registration using a factory delegate:I've put together a blog post covering this now - the answer marked as correct isn't actually right - MemoryCacheService needs to be a singleton because it contains a MemoryCache instance that needs to be shared across all dependent instances.