注册DynaCaches与SimpleInjector [英] Registering DynaCaches with SimpleInjector

查看:137
本文介绍了注册DynaCaches与SimpleInjector的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我在尝试使用动态缓存在我的解决方案来缓存数据我从数据库返回所以当我用的Telerik格来过滤数据页等我没有回去的DB每次来获取数据。

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.

在动态缓存页的示例可以看出它正在与Ninject DI如下使用:

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>());

我使用 SimpleInjector 我的DI容器。有没有人使用动态缓存与SimpleInjector因为我有在得到正确的语法注册动态缓存与SimpleInjector它显示在Ninject以同样的方式有些困难

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

推荐答案

我已经把一个的博客文章现已覆盖本 - 答案标记为正确的其实不是正确的 - MemoryCacheService必须是单身,因为它包含一个需要所有相关的实例共享一个实例的MemoryCache

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.

这篇关于注册DynaCaches与SimpleInjector的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆