Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/catcherwong/ocelot.cache.easycaching
🚀 Repo for EasyCaching integration with Ocelot
https://github.com/catcherwong/ocelot.cache.easycaching
cache easycaching ocelot
Last synced: 3 months ago
JSON representation
🚀 Repo for EasyCaching integration with Ocelot
- Host: GitHub
- URL: https://github.com/catcherwong/ocelot.cache.easycaching
- Owner: catcherwong
- License: mit
- Created: 2019-07-16T08:11:33.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-10-07T02:39:03.000Z (over 3 years ago)
- Last Synced: 2024-08-30T16:37:16.188Z (5 months ago)
- Topics: cache, easycaching, ocelot
- Language: C#
- Homepage:
- Size: 24.4 KB
- Stars: 7
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ocelot.Cache.EasyCaching
[![nuget](https://img.shields.io/nuget/v/Ocelot.Cache.EasyCaching.svg)](https://www.nuget.org/packages/Ocelot.Cache.EasyCaching/) [![GitHub license](https://img.shields.io/github/license/catcherwong/Ocelot.Cache.EasyCaching.svg)](https://github.com/catcherwong/Ocelot.Cache.EasyCaching/blob/master/LICENSE)
This package adds [EasyCaching](https://github.com/dotnetcore/EasyCaching) support to Ocelot.
## How to install
Install it via Nuget.
`Install-Package Ocelot.Cache.EasyCaching`
Or via the .NET Core CLI:
`dotnet add package Ocelot.Cache.EasyCaching`
## How to use
Config `EasyCaching` in `ConfigureServices`
```cs
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseUrls("http://*:9000")
.ConfigureAppConfiguration((hostingContext, config) =>
{
config
.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
.AddJsonFile("ocelot.json")
.AddEnvironmentVariables();
})
.ConfigureServices(services =>
{
services.AddOcelot()
.AddEasyCaching(x =>
{
// single
x.EnableHybrid = false;
x.ProviderName = "m1";
x.Settings = y =>
{
y.UseInMemory("m1");
};//// hybrid
//x.IsHybird = true;
//x.ProviderName = "";
//x.Action = y =>
//{
// y.UseInMemory("m2");
// y.UseCSRedis(z =>
// {
// z.DBConfig = new CSRedisDBOptions
// {
// ConnectionStrings = new System.Collections.Generic.List
// {
// "127.0.0.1:6379,defaultDatabase=11,poolsize=10"
// }
// };
// }, "r2");// y.UseHybrid(z =>
// {
// z.LocalCacheProviderName = "m2";
// z.DistributedCacheProviderName = "r2";
// z.TopicName = "caching-bus";
// });// y.WithCSRedisBus(z =>
// {
// z.ConnectionStrings = new System.Collections.Generic.List
// {
// "127.0.0.1:6379,defaultDatabase=10,poolsize=10"
// };
// });
//};
});
})
.Configure(app =>
{
app.UseOcelot().Wait();
});
});
```