Кэширование Ocelot: AddCacheManager Попробуйте явно указать аргументы типа error - PullRequest
0 голосов
/ 10 апреля 2020

Новое в Ocelot и. net ядро. Я пытаюсь реализовать кэширование в. net ядре 3.0 микросервиса в шлюзе Ocelot. Согласно руководству Ocelot (https://ocelot.readthedocs.io/en/latest/features/caching.html)

На втором шаге мой startup.cs выглядит следующим образом:

using System.Text;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;

namespace MS_APIGateway
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddOcelot().AddCacheManager(x => **// Getting error here**
                {
                    x.WithDictionaryHandle(); 
                });
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public async void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();
            //JWT
            app.UseAuthentication();
            //JWT
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
            await app.UseOcelot();
        }
    }
}


Компилятор выдает ошибку на AddCacheManager строка и сообщение об ошибке:

Error   CS0411  The type arguments for method 'ServiceCollectionExtensions.AddCacheManager<T>(IServiceCollection, IConfiguration, string, Action<ConfigurationBuilder>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

Пожалуйста, помогите. Спасибо.

1 Ответ

0 голосов
/ 10 апреля 2020

мы должны добавить using Ocelot.Cache.CacheManager;

...