ConfigureServices中添加分布式缓存,services.AddDistributedMemoryCache(); 微软官方建议使用AddDistributedMemoryCache,当然也可以使用AddDistributedRedisCache...、AddDistributedSqlServerCache或者自定义缓存也是可以的; 如果是分布式系统或者SSO单点登录,建议使用分布式的缓存AddDistributedRedisCache,AddDistributedSqlServerCache
ConfigureServices(IServiceCollection services) { services.AddMvc(); //添加redis services.AddDistributedRedisCache
13 public static IServiceCollection AddDistributedRedisCache(this IServiceCollection services...引入完了Microsoft.Extensions.Caching.Redis之后,在Startup类中: 1 services.AddDistributedRedisCache(option => 2
services.AddSession(); #region 使用Redis保存Session // 这里取连接字符串 services.AddDistributedRedisCache...services.AddDistributedRedisCache:将Session保存到Redis数据库。 services.AddSession:配置Sesion策略。
下面的演示程序调用了AddDistributedRedisCache扩展方法添加了基于DistributedRedisCache的服务注册,SessionMiddleware中间件则通过调用UseSession...using System.Text; var builder = WebApplication.CreateBuilder(); builder.Services .AddDistributedRedisCache
Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.DependencyInjection; var cache = new ServiceCollection().AddDistributedRedisCache...IDistributedCache服务的注册是通过调用IServiceCollection接口的AddDistributedRedisCache方法来完成的。
来支持分布式缓存,在开发测试或单主机服务中,需使用以下代码进行注入: services.AddDistributedMemoryCache(); 如需使用Redis,请参考下面代码: services.AddDistributedRedisCache
Redis 分布式缓存配置 public void ConfigureServices(IServiceCollection services) { services.AddDistributedRedisCache...Configuration 和 ConfigurationOptions 的作用是相同的,一旦设置了 ConfigurationOptions ,就不应该再去设置属性 Configuration 的值,因为,在 AddDistributedRedisCache
public void ConfigureServices(IServiceCollection services, IWebHostEnvironment env) { services.AddDistributedRedisCache
WebHostBuilder() 6: .UseKestrel() 7: .ConfigureServices(svcs => svcs.AddDistributedRedisCache...我们调用IServiceCollection的另一个扩展方法AddDistributedRedisCache注册DistributedCache服务,在调用这个方法的时候借助于RedisCacheOptions
services.AddDataProtection() .PersisitKeysToRedis() .SetApplicationName("myapp-redis-keystore"); services.AddDistributedRedisCache
public void ConfigureServices(IServiceCollection services) { services.AddDistributedRedisCache(r
领取专属 10元无门槛券
手把手带您无忧上云