-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a116d5d
commit 86027b6
Showing
11 changed files
with
387 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
coming soon! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
coming soon! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
coming soon! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
coming soon! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
EasyCaching.InMemory is a in-memory caching lib which is based on **EasyCaching.Core** and **Microsoft.Extensions.Caching.Memory**. | ||
|
||
When you use this lib , it means that you will handle the memory of current server . As usual , we named it as local caching . | ||
|
||
## How to use ? | ||
|
||
### 1. Install the package via Nuget | ||
|
||
``` | ||
Install-Package EasyCaching.InMemory | ||
``` | ||
|
||
### 2. Config in Startup class | ||
|
||
```csharp | ||
public class Startup | ||
{ | ||
//... | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
//other services. | ||
//Important step for In-Memory Caching | ||
services.AddDefaultInMemoryCache(); | ||
} | ||
} | ||
``` | ||
|
||
### 3. Call the EasyCachingProvider | ||
|
||
The following code show how to use EasyCachingProvider in ASP.NET Core Web API. | ||
|
||
```csharp | ||
[Route("api/[controller]")] | ||
public class ValuesController : Controller | ||
{ | ||
private readonly IEasyCachingProvider _provider; | ||
|
||
public ValuesController(IEasyCachingProvider provider) | ||
{ | ||
this._provider = provider; | ||
} | ||
|
||
[HttpGet] | ||
public string Get() | ||
{ | ||
//Remove | ||
_provider.Remove("demo"); | ||
|
||
//Set | ||
_provider.Set("demo", "123", TimeSpan.FromMinutes(1)); | ||
|
||
//Get | ||
var res = _provider.Get("demo", () => "456", TimeSpan.FromMinutes(1)); | ||
|
||
//Get without data retriever | ||
var res = _provider.Get<string>("demo"); | ||
|
||
//Remove Async | ||
await _provider.RemoveAsync("demo"); | ||
|
||
//Set Async | ||
await _provider.SetAsync("demo", "123", TimeSpan.FromMinutes(1)); | ||
|
||
//Get Async | ||
var res = await _provider.GetAsync("demo",async () => await Task.FromResult("456"), TimeSpan.FromMinutes(1)); | ||
|
||
//Get without data retriever Async | ||
var res = await _provider.GetAsync<string>("demo"); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
![](https://raw.githubusercontent.com/catcherwong/EasyCaching/master/media/easycaching-icon.png) | ||
|
||
EasyCaching is a open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier! | ||
|
||
[![Coverage Status](https://coveralls.io/repos/github/catcherwong/EasyCaching/badge.svg?branch=master)](https://coveralls.io/github/catcherwong/EasyCaching?branch=master) | ||
|
||
[![GitHub license](https://img.shields.io/github/license/catcherwong/EasyCaching.svg)](https://github.com/catcherwong/EasyCaching/blob/master/LICENSE) | ||
|
||
## CI Build Status | ||
|
||
| Platform | Build Server | Status | | ||
|--------- |------------- |---------| | ||
| AppVeyor | Windows |[![Build status](https://ci.appveyor.com/api/projects/status/ji7513h4uv4ysq2i?svg=true)](https://ci.appveyor.com/project/catcherwong/easycaching) | | ||
| Travis | Linux/OSX | [![Build Status](https://travis-ci.org/catcherwong/EasyCaching.svg?branch=master)](https://travis-ci.org/catcherwong/EasyCaching) | | ||
|
||
## Nuget Packages | ||
|
||
| Package Name | Version | Downloads | ||
|--------------| ------- | ---- | ||
| EasyCaching.Core | ![](https://img.shields.io/nuget/v/EasyCaching.Core.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Core.svg) | ||
| EasyCaching.InMemory | ![](https://img.shields.io/nuget/v/EasyCaching.InMemory.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.InMemory.svg) | ||
| EasyCaching.Redis | ![](https://img.shields.io/nuget/v/EasyCaching.Redis.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Redis.svg) | ||
| EasyCaching.Memcached | ![](https://img.shields.io/nuget/v/EasyCaching.Memcached.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Memcached.svg) | ||
| EasyCaching.SQLite | ![](https://img.shields.io/nuget/v/EasyCaching.SQLite.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.SQLite.svg) | ||
| EasyCaching.Serialization.MessagePack | ![](https://img.shields.io/nuget/v/EasyCaching.Serialization.MessagePack.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Serialization.MessagePack.svg) | ||
| EasyCaching.Interceptor.Castle | ![](https://img.shields.io/nuget/v/EasyCaching.Interceptor.Castle.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Interceptor.Castle.svg) | ||
| EasyCaching.Interceptor.AspectCore | ![](https://img.shields.io/nuget/v/EasyCaching.Interceptor.AspectCore.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Interceptor.AspectCore.svg) | ||
| EasyCaching.HybridCache | ![](https://img.shields.io/nuget/v/EasyCaching.HybridCache.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.HybridCache.svg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
EasyCaching.Memcached is a memcached caching lib which is based on **EasyCaching.Core** and **[EnyimMemcachedCore](https://github.com/cnblogs/EnyimMemcachedCore)**. | ||
|
||
When you use this lib , it means that you will handle the data of your memcached servers . As usual , we will use it as distributed caching . | ||
|
||
# How to use ? | ||
|
||
## Basic Usages | ||
|
||
### 1. Install the package via Nuget | ||
|
||
``` | ||
Install-Package EasyCaching.Memcached | ||
``` | ||
|
||
### 2. Config in Startup class | ||
|
||
```csharp | ||
public class Startup | ||
{ | ||
//... | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddMvc(); | ||
|
||
//Important step for Memcached Cache | ||
services.AddDefaultMemcached(option=> | ||
{ | ||
option.AddServer("127.0.0.1",11211); | ||
}); | ||
} | ||
|
||
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | ||
{ | ||
//Important step for Memcache Cache | ||
app.UseDefaultMemcached(); | ||
} | ||
} | ||
``` | ||
|
||
### 3. Call the EasyCachingProvider | ||
|
||
The following code show how to use EasyCachingProvider in ASP.NET Core Web API. | ||
|
||
```csharp | ||
[Route("api/[controller]")] | ||
public class ValuesController : Controller | ||
{ | ||
private readonly IEasyCachingProvider _provider; | ||
|
||
public ValuesController(IEasyCachingProvider provider) | ||
{ | ||
this._provider = provider; | ||
} | ||
|
||
[HttpGet] | ||
public string Get() | ||
{ | ||
//Remove | ||
_provider.Remove("demo"); | ||
|
||
//Set | ||
_provider.Set("demo", "123", TimeSpan.FromMinutes(1)); | ||
|
||
//Get | ||
var res = _provider.Get("demo", () => "456", TimeSpan.FromMinutes(1)); | ||
|
||
//Get without data retriever | ||
var res = _provider.Get<string>("demo"); | ||
|
||
//Remove Async | ||
await _provider.RemoveAsync("demo"); | ||
|
||
//Set Async | ||
await _provider.SetAsync("demo", "123", TimeSpan.FromMinutes(1)); | ||
|
||
//Get Async | ||
var res = await _provider.GetAsync("demo",async () => await Task.FromResult("456"), TimeSpan.FromMinutes(1)); | ||
|
||
//Get without data retriever Async | ||
var res = await _provider.GetAsync<string>("demo"); | ||
|
||
//Refresh | ||
_provider.Refresh("key", "123", TimeSpan.FromMinutes(1)); | ||
|
||
//Refresh Async | ||
await _provider.RefreshAsync("key", "123", TimeSpan.FromMinutes(1)); | ||
} | ||
} | ||
``` | ||
|
||
## Advanced Usages | ||
|
||
As we all know , before we store data in redis database , the data need to be serialized ! | ||
|
||
**EnyimMemcachedCore** contains a default serializer that uses **System.Runtime.Serialization.Formatters.Binary** to handle (de)serialization . | ||
|
||
However , performance of the default serializer is not very well ! Many of us can choose another serializer to handle (de)serialization . | ||
|
||
### 1.Install the serialization pack via Nuget | ||
|
||
``` | ||
Install-Package EasyCaching.Serialization.MessagePack | ||
``` | ||
|
||
### 2. Config in Startup class | ||
|
||
```csharp | ||
public class Startup | ||
{ | ||
//... | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
//other services. | ||
//Important step for Redis Caching | ||
services.AddDefaultMemcached(option=> | ||
{ | ||
option.AddServer("127.0.0.1",11211); | ||
//specify the Transcoder use messagepack . | ||
option.Transcoder = new MessagePackFormatterTranscoder(new DefaultMessagePackSerializer()) ; | ||
}); | ||
} | ||
|
||
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | ||
{ | ||
//Important step for Memcache Cache | ||
app.UseDefaultMemcached(); | ||
} | ||
} | ||
``` | ||
|
||
### 3 Call Memcached Caching Provider | ||
|
||
The same as the basic usage ! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
coming soon! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
EasyCaching.Redis is a redis caching lib which is based on **EasyCaching.Core** and **StackExchange.Redis**. | ||
|
||
When you use this lib , it means that you will handle the data of your redis servers . As usual , we will use it as distributed caching . | ||
|
||
# How to use ? | ||
|
||
## Basic Usages | ||
|
||
### 1. Install the package via Nuget | ||
|
||
``` | ||
Install-Package EasyCaching.Redis | ||
``` | ||
|
||
### 2. Config in Startup class | ||
|
||
```csharp | ||
public class Startup | ||
{ | ||
//... | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
//other services. | ||
//Important step for Redis Caching | ||
services.AddDefaultRedisCache(option=> | ||
{ | ||
option.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379)); | ||
option.Password = ""; | ||
}); | ||
} | ||
} | ||
``` | ||
|
||
### 3. Call the EasyCachingProvider | ||
|
||
The following code show how to use EasyCachingProvider in ASP.NET Core Web API. | ||
|
||
```csharp | ||
[Route("api/[controller]")] | ||
public class ValuesController : Controller | ||
{ | ||
private readonly IEasyCachingProvider _provider; | ||
|
||
public ValuesController(IEasyCachingProvider provider) | ||
{ | ||
this._provider = provider; | ||
} | ||
|
||
[HttpGet] | ||
public string Get() | ||
{ | ||
//Remove | ||
_provider.Remove("demo"); | ||
|
||
//Set | ||
_provider.Set("demo", "123", TimeSpan.FromMinutes(1)); | ||
|
||
//Get | ||
var res = _provider.Get("demo", () => "456", TimeSpan.FromMinutes(1)); | ||
|
||
//Get without data retriever | ||
var res = _provider.Get<string>("demo"); | ||
|
||
//Remove Async | ||
await _provider.RemoveAsync("demo"); | ||
|
||
//Set Async | ||
await _provider.SetAsync("demo", "123", TimeSpan.FromMinutes(1)); | ||
|
||
//Get Async | ||
var res = await _provider.GetAsync("demo",async () => await Task.FromResult("456"), TimeSpan.FromMinutes(1)); | ||
|
||
//Get without data retriever Async | ||
var res = await _provider.GetAsync<string>("demo"); | ||
|
||
//Refresh | ||
_provider.Refresh("key", "123", TimeSpan.FromMinutes(1)); | ||
|
||
//Refresh Async | ||
await _provider.RefreshAsync("key", "123", TimeSpan.FromMinutes(1)); | ||
} | ||
} | ||
``` | ||
|
||
## Advanced Usages | ||
|
||
As we all know , before we store data in redis database , the data need to be serialized ! | ||
|
||
**EasyCaching.Redis** contains a default serializer that uses **System.Runtime.Serialization.Formatters.Binary** to handle (de)serialization . | ||
|
||
However , performance of the default serializer is not very well ! Many of us can choose another serializer to handle (de)serialization . | ||
|
||
### 1.Install the serialization pack via Nuget | ||
|
||
``` | ||
Install-Package EasyCaching.Serialization.MessagePack | ||
``` | ||
|
||
### 2. Config in Startup class | ||
|
||
```csharp | ||
public class Startup | ||
{ | ||
//... | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
//other services. | ||
//Important step for Redis Caching | ||
services.AddDefaultRedisCache(option=> | ||
{ | ||
option.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379)); | ||
option.Password = ""; | ||
}); | ||
//Important step for MessagePack Serializer | ||
services.AddDefaultMessagePackSerializer(); | ||
} | ||
} | ||
``` | ||
|
||
### 3 Call Redis Caching Provider | ||
|
||
The same as the basic usage ! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
coming soon! |
Oops, something went wrong.