public IActionResult GetRedisSecretConfigByCustomMethod() { // 读取自定义json文件 RedisHostOptions redisOption = JsonConfigHelper.GetAppSettings <RedisHostOptions>("JsonFile/secret.json", "redis"); return(Ok(redisOption)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { OptionConfigure(services); CustomOptionConfigure(services); services.AddEasyCaching(options => { options.UseRedis(configure => { RedisHostOptions redisOption = JsonConfigHelper.GetAppSettings <RedisHostOptions>("JsonFile/secret.json", "redis"); configure.DBConfig.Endpoints.Add(new EasyCaching.Core.Configurations.ServerEndPoint(redisOption.host, redisOption.port)); configure.DBConfig.AllowAdmin = true; }, "RedisExample"); }); services.AddControllers(); }