mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 04:38:14 +08:00
Added some basic cache stuff
This commit is contained in:
@ -1,10 +1,13 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using System;
|
||||
using CacheManager.Core;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ocelot.DependencyInjection;
|
||||
using Ocelot.Middleware;
|
||||
using ConfigurationBuilder = Microsoft.Extensions.Configuration.ConfigurationBuilder;
|
||||
|
||||
namespace Ocelot.ManualTest
|
||||
{
|
||||
@ -27,6 +30,16 @@ namespace Ocelot.ManualTest
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
Action<ConfigurationBuilderCachePart> settings = (x) =>
|
||||
{
|
||||
x.WithMicrosoftLogging(log =>
|
||||
{
|
||||
log.AddConsole(LogLevel.Debug);
|
||||
})
|
||||
.WithDictionaryHandle();
|
||||
};
|
||||
|
||||
services.AddOcelotOutputCaching(settings);
|
||||
services.AddOcelotFileConfiguration(Configuration);
|
||||
services.AddOcelot();
|
||||
}
|
||||
|
@ -40,7 +40,8 @@
|
||||
{
|
||||
"DownstreamTemplate": "http://jsonplaceholder.typicode.com/posts",
|
||||
"UpstreamTemplate": "/posts",
|
||||
"UpstreamHttpMethod": "Get"
|
||||
"UpstreamHttpMethod": "Get",
|
||||
"FileCacheOptions": { "TtlSeconds": 15 }
|
||||
},
|
||||
{
|
||||
"DownstreamTemplate": "http://jsonplaceholder.typicode.com/posts/{postId}",
|
||||
|
Reference in New Issue
Block a user