https://github.com/dotnetcore/EasyCaching
:boom: EasyCaching is an open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier!
https://github.com/dotnetcore/EasyCaching
aspnetcore cache caching distributed-cache hybrid-cache interceptor memcached memory-cache redis sqlite
Last synced: 24 days ago
JSON representation
:boom: EasyCaching is an open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier!
- Host: GitHub
- URL: https://github.com/dotnetcore/EasyCaching
- Owner: dotnetcore
- License: mit
- Created: 2017-11-11T08:53:56.000Z (over 7 years ago)
- Default Branch: dev
- Last Pushed: 2024-12-25T06:00:20.000Z (3 months ago)
- Last Synced: 2024-12-30T21:15:50.575Z (3 months ago)
- Topics: aspnetcore, cache, caching, distributed-cache, hybrid-cache, interceptor, memcached, memory-cache, redis, sqlite
- Language: C#
- Homepage:
- Size: 3.43 MB
- Stars: 1,982
- Watchers: 76
- Forks: 327
- Open Issues: 44
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: code-of-conduct.md
Awesome Lists containing this project
- awesome-csharp - EasyCaching - A caching library that contains basic and some advanced usages of caching which can help handle caching more easier! (Caching)
- awesome-dotnet-cn - EasyCaching - 缓存库,包含缓存的基本用法和一些高级用法,可以使缓存处理更容易。 (缓存)
- awesome-dotnet-core - EasyCaching - Open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier. (Frameworks, Libraries and Tools / Caching)
- awsome-dotnet - EasyCaching - A caching library that contains basic and some advanced usages of caching which can help handle caching more easier! (Caching)
- fucking-awesome-dotnet-core - EasyCaching - Open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier. (Frameworks, Libraries and Tools / Caching)
- awesome-dotnet - EasyCaching - A caching library that contains basic and some advanced usages of caching which can help handle caching more easier! (Caching)
- awesome-dotnet-core - EasyCaching - Open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier. (Frameworks, Libraries and Tools / Caching)
- awesome-dotnet-core - EasyCaching - 开源缓存库,包含基本用法和缓存的一些高级用法,可以帮助我们更轻松地处理缓存。 (框架, 库和工具 / 缓存)
- awesome-dotnet - EasyCaching - 💥 EasyCaching is an open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier! (Libraries, Frameworks and Tools / Caching)
README

EasyCaching is an open-source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easily!
[](https://coveralls.io/github/catcherwong/EasyCaching?branch=master)
[](https://github.com/dotnetcore)
[](https://github.com/dotnetcore/EasyCaching/blob/master/LICENSE)
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fdotnetcore%2FEasyCaching?ref=badge_shield)## CI Build Status
| Platform | Build Server | Master Status | Dev Status |
|--------- |------------- |---------|---------|
| Github Action | Linux/Windows | [](https://github.com/dotnetcore/EasyCaching/actions/workflows/buildandtest.yml) | [](https://github.com/dotnetcore/EasyCaching/actions/workflows/buildandtest.yml) |## Nuget Packages
| Package Name | Version | Downloads
|-----------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------| ---------------------------------------------------------------------------------
| [EasyCaching.Core](https://www.nuget.org/packages/EasyCaching.Core) |  | 
| [EasyCaching.InMemory](https://www.nuget.org/packages/EasyCaching.InMemory) |  | 
| [EasyCaching.Redis](https://www.nuget.org/packages/EasyCaching.Redis) |  | 
| [EasyCaching.Memcached](https://www.nuget.org/packages/EasyCaching.Memcached) |  | 
| [EasyCaching.SQLite](https://www.nuget.org/packages/EasyCaching.SQLite) |  | 
| [EasyCaching.HybridCache](https://www.nuget.org/packages/EasyCaching.HybridCache) |  | 
| [EasyCaching.CSRedis](https://www.nuget.org/packages/EasyCaching.CSRedis) |  | 
| [EasyCaching.FreeRedis](https://www.nuget.org/packages/EasyCaching.FreeRedis) |  | 
| [EasyCaching.FasterKv](https://www.nuget.org/packages/EasyCaching.FasterKv) |  | 
| [EasyCaching.Disk](https://www.nuget.org/packages/EasyCaching.Disk) |  | 
| [EasyCaching.LiteDB](https://www.nuget.org/packages/EasyCaching.LiteDB) |  | 
| [EasyCaching.Interceptor.Castle](https://www.nuget.org/packages/EasyCaching.Interceptor.Castle) |  | 
| [EasyCaching.Interceptor.AspectCore](https://www.nuget.org/packages/EasyCaching.Interceptor.AspectCore) |  | 
| [EasyCaching.Serialization.MessagePack](https://www.nuget.org/packages/EasyCaching.Serialization.MessagePack) |  | 
| [EasyCaching.Serialization.Json](https://www.nuget.org/packages/EasyCaching.Serialization.Json) |  | 
| [EasyCaching.Serialization.SystemTextJson](https://www.nuget.org/packages/EasyCaching.Serialization.SystemTextJson) |  | 
| [EasyCaching.Serialization.Protobuf](https://www.nuget.org/packages/EasyCaching.Serialization.Protobuf) |  | 
| [EasyCaching.Serialization.MemoryPack](https://www.nuget.org/packages/EasyCaching.Serialization.MessagePack) |  | 
| [EasyCaching.Bus.RabbitMQ](https://www.nuget.org/packages/EasyCaching.Bus.RabbitMQ) |  | 
| [EasyCaching.Bus.RabbitMQStream](https://www.nuget.org/packages/EasyCaching.Bus.RabbitMQStream) |  | 
| [EasyCaching.Bus.Redis](https://www.nuget.org/packages/EasyCaching.Bus.Redis) |  | 
| [EasyCaching.Bus.CSRedis](https://www.nuget.org/packages/EasyCaching.Bus.CSRedis) |  | 
| [EasyCaching.Bus.ConfluentKafka](https://www.nuget.org/packages/EasyCaching.Bus.ConfluentKafka) |  | 
| [EasyCaching.Bus.Zookeeper](https://www.nuget.org/packages/EasyCaching.Bus.Zookeeper) |  | 
| [EasyCaching.ResponseCaching](https://www.nuget.org/packages/EasyCaching.ResponseCaching) |  | ## Basic Usages
### Step 1 : Install the package
Choose caching provider that you need and install it via Nuget.
```
Install-Package EasyCaching.InMemory
Install-Package EasyCaching.Redis
Install-Package EasyCaching.SQLite
Install-Package EasyCaching.Memcached
Install-Package EasyCaching.FasterKv
```### Step 2 : Configure Startup class
Each caching provider has it's own configuration options.
Here is a sample configuration for InMemory and Redis caching provider.
```csharp
public class Startup
{
//...
public void ConfigureServices(IServiceCollection services)
{
//configuration
services.AddEasyCaching(options =>
{
//use memory cache that named default
options.UseInMemory("default");// // use memory cache with your own configuration
// options.UseInMemory(config =>
// {
// config.DBConfig = new InMemoryCachingOptions
// {
// // scan time, default value is 60s
// ExpirationScanFrequency = 60,
// // total count of cache items, default value is 10000
// SizeLimit = 100
// };
// // the max random second will be added to cache's expiration, default value is 120
// config.MaxRdSecond = 120;
// // whether enable logging, default is false
// config.EnableLogging = false;
// // mutex key's alive time(ms), default is 5000
// config.LockMs = 5000;
// // when mutex key alive, it will sleep some time, default is 300
// config.SleepMs = 300;
// }, "m2");//use redis cache that named redis1
options.UseRedis(config =>
{
config.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379));
}, "redis1")
.WithMessagePack()//with messagepack serialization
;
});
}
}
```### Step 3 : Write code in your controller
```csharp
[Route("api/[controller]")]
public class ValuesController : Controller
{
// //when using single provider
// private readonly IEasyCachingProvider _provider;
//when using multiple provider
private readonly IEasyCachingProviderFactory _factory;public ValuesController(
//IEasyCachingProvider provider,
IEasyCachingProviderFactory factory
)
{
//this._provider = provider;
this._factory = factory;
}[HttpGet]
public string Handle()
{
//var provider = _provider;
//get the provider from factory with its name
var provider = _factory.GetCachingProvider("redis1");//Set
provider.Set("demo", "123", TimeSpan.FromMinutes(1));
//Set Async
await provider.SetAsync("demo", "123", TimeSpan.FromMinutes(1));
}
}
```## Documentation
Detailed EasyCaching documentation can be found [here](http://easycaching.readthedocs.io/en/latest/).
## Extension Libs
| Package Name | Downloads | Description
|-------------------------------------------------------------------------------------------------------------------------------------------------------| ----------------------------------------------------------------------------------| -------------------------------------------------------------------------------------------------------------------------------
| [EasyCaching.Extensions.EasyCompressor](https://github.com/mjebrahimi/EasyCompressor/blob/master/src/EasyCaching.Extensions.EasyCompressor/README.md) |  | Compress your cache objects to speedup transferring data over network, reduce bandwidth usage, and memory usage of cache server
| [EasyCaching.Extensions](https://github.com/yrinleung/EasyCaching.Extensions) | | EasyCaching integration for CAP, WebApiClient, IDistributedCache, ...## Examples
See [sample](https://github.com/catcherwong/EasyCaching/tree/master/sample)
## Todo List
See [ToDo List](docs/ToDoList.md)
## Contributing
Pull requests, issues and commentary!
## License
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fdotnetcore%2FEasyCaching?ref=badge_large)