.NET Core 3中的Redis缓存是否需要使用Stack Exchange软件包? [英] Does Redis Cache in .NET Core 3 requires the usage of the Stack Exchange package?

查看:42
本文介绍了.NET Core 3中的Redis缓存是否需要使用Stack Exchange软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.NET Core 2.2中,在我的 Startup.cs 中,我具有以下内容:

In .NET Core 2.2, in my Startup.cs, I had the following:

public void ConfigureServices(IServiceCollection services)
{
    services.AddDistributedRedisCache(...);             
}

但是现在,在.NET Core 3.0中,找不到 AddDistributedRedisCache 方法.在 docs ,适用于"部分仅显示对.NET Core 2.2的支持.

But now, in .NET Core 3.0, the AddDistributedRedisCache method can't be found. In docs, the "Applies to" section shows support only up to .NET Core 2.2

遵循

Following this tutorial from Microsoft, they use services.AddStackExchangeRedisCache in the example. Does it means that I'm required to install the Stack Exchange NuGet package for Redis? Why did the native Microsoft's Redis client solution removed?

推荐答案

在他们的git存储库中进行了一些挖掘,但已将其删除.在当前存储库 https://github.com/aspnet/Extensions 中,没有发生删除操作,但在以前已存储的以前的存储库中, https://github.com/aspnet/Caching

It took a bit of digging through their git repos, but it has been removed. The removal did not happen in the current repository, https://github.com/aspnet/Extensions, but in the previous repository, that is now archived, https://github.com/aspnet/Caching.

您可以在此线程中看到原始软件包的一些问题:https://github.com/aspnet/Caching/issues/410#issuecomment-418912525

You can see some of the issues with the original package in this thread: https://github.com/aspnet/Caching/issues/410#issuecomment-418912525

删除发生在这里: https://github.com/aspnet/Caching/issues/423

我浏览了从2.1-> 2.2和2.2-> 3.0的aspnet重大更改列表,但没有列出任何内容.我将在文档中创建一个问题以查看它是否包含在内.

I've looked through the list of breaking changes in aspnet from 2.1 -> 2.2 and 2.2 -> 3.0 and nothing is listed for it. I'm going to create an issue on the documentation to see it included.

在这一点上,我相信答案是使用StackExchange版本.无论如何,它显然比旧的软件包有了一些重大改进.

At this point, I believe the answer is to use the StackExchange version. It apparently has some major improvements over the older package anyway.

更新:受支持的最新程序包是 Microsoft.Extensions.Caching.StackExchangeRedis ,仅使用此程序包最适合.NET Core 3.0及更高版本.

UPDATE: The latest package supported would be Microsoft.Extensions.Caching.StackExchangeRedis simply utilising this package would be best for .NET Core 3.0 and above.

类似的东西

services.AddStackExchangeRedisCache(action =>
                {
                    action.InstanceName = "WhatYouWantToNameIt";
                    action.Configuration = "127.0.0.1:6379";
                });

文档为 查看全文

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