- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
IDistributedCache作为标准 API 提供,用于从 ASP.NET 应用程序中访问分布式缓存。提供的 API 非常简单,基本上将缓存呈现为键值对的容器,DistributedCacheEntryOptions提供每次入场的到期选项。
现在假设在一个应用程序中有许多不同类型的数据需要缓存,其中一些我们可能希望在逻辑上进行分组。也许我们希望对某些类型的数据进行分组,以便我们可以例如选择从缓存中全部刷新而不影响其他类型的数据,或者我们希望能够将某些类型的数据放在具有高可用性的不同缓存集群中,或者更多资源以获得更好的性能等。
鉴于此,我倾向于拥有一个包含多个 IDistributedCache 实例的包含对象,每个实例用于逻辑分组。鉴于这似乎是一个常见的要求,我想知道是否有一些标准的方法可以实现这种模式。或者建议将所有内容放入一个带有复合键(例如 groupName-key)的缓存中,尽管我不希望这样做,因为我认为这会限制缓存层的灵 active 。
顺便说一句,我注意到 NCache API 提供了为每个缓存条目选择分配 groupName 和 subGroupName 的能力,我认为这正是我想要的。但是,我更愿意针对 IDistributedCache (或类似的)进行编码,以允许插入式替代缓存实现。
也许另一种选择是创建我自己的接口(interface)来提供抽象,但是我没有选择使用预先构建的现成 IDistributedCache 实现(例如来自 NCache 和 Redis)。
另见:https://github.com/aspnet/Extensions/issues/2802
最佳答案
... within a single app there are lots of different types of data to be cached, some of which we may wish to logically group.
public interface IDistributedCache01 : IDistributedCache { ... }
public interface IDistributedCache02 : IDistributedCache { ... }
services.AddSingleton<IDistributedCache01, SqlServerCache>();
services.AddSingleton<IDistributedCache02, SqlServerCache>();
public MyController(IDistributedCache01 cache)
{
_cache = cache;
}
services.AddSingleton<IDistributedCache, SqlServerCache>();
services.Configure(setupAction);
关于caching - IDistributedCache 的多个实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50822279/
IDistributedCache作为标准 API 提供,用于从 ASP.NET 应用程序中访问分布式缓存。提供的 API 非常简单,基本上将缓存呈现为键值对的容器,DistributedCacheE
我正在使用 services.AddDistributedMemoryCache()在我的 .Net Core 3 Web API 中 startup.cs类(class)。当我第一次设置缓存时: p
我有一个 asp.net core 项目,我正在尝试使用 IDistributedCache (Redis)。 我想在自定义类中访问 IDistributedCache,而不仅仅是在 Controll
我将用户生成的一些 key 存储在 IDistributedCache 设置中。 key 是长期存在的,如果用户知道它们中的每一个,它们可以由用户手动撤销: public void Configure
我正在使用 .NET Core 2.0 和 Microsoft.Extensions.Caching.Redis 2.0。为什么 IDistributedCache.SetStringAsync 实际
我有一个基于asp.net core 2.1解决方案使用redis分布式缓存的项目。有些东西我还不明白。 我有一个类 myClassName,它的构造函数需要注入(inject)。 public cl
我有一个 Azure Redis 和 .Net Core 2 的工作实现,使用的代码与此 article 中描述的非常相似 我的问题是,如何从单元测试类实例化缓存实例?我查看了许多资源,但一无所获。
.Net Core 为两个接口(interface)( MemoryCache 和 DistributedMemoryCache )提供内存实现,但假设我们有一个可用的 IDistributedCac
我在 ASP.Net Core 2.2 API 中将 IDistributedCache 与 SQL Server 结合使用。 我注意到过期的记录仍然保留在表中。有没有办法删除缓存表中过期的记录? 最
希望我能得到一些关于哪种缓存机制最适合 Azure 的说明。 目前我的应用程序使用内存中 (IMemoryCache) 来保存经常访问的数据。 此功能是否与在单个 Web 服务器上一样?即存储在内存中
为了实现多个 IDistributedCache 定义,我有以下解决方案: public interface IDBCache : IDistributedCache { } public class
我正在 .net core 2.0 中构建 web api 并将其部署在 kubernetes 上。我想将 IDistributedCache(带有 redis)与哨兵和主/从配置一起使用。我找不到任
我需要使用 IDistributedCache在我的应用程序中,它可能是 MemoryDistributedCache或 RedisCache作为底层实现。我的理解是这些不是线程安全的,所以我创建了自
我正在使用带有 aws redis 缓存的 .net core api (2.1)。我没有看到将到期时间设置为 IDistributedCache.SetAsync 的方法.这怎么可能? 我的代码段如
我有一个 ASP.NET Core2 应用程序。我同时使用内置和 Autofac IoC 容器。我正在 Startup.cs 文件中设置所有组件注册。在执行此操作时,我还设置了我的 DBContext
我想在 ASP.NET Core 项目中实现分布式缓存(Redis)。经过一番研究后,我发现有两种方法可以使用 Startup.cs 和 ConnectionMultiplexer 中的 AddSta
我正在尝试在 MVC 6 中使用 Redis 缓存,但我无法构建我的项目。 我遵循了 https://github.com/aspnet/Caching/tree/dev/samples 中的示例-
我是一名优秀的程序员,十分优秀!