-
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
9319b1b
commit 1fd9023
Showing
6 changed files
with
159 additions
and
9 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
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,84 @@ | ||
# DefaultFasterKvCachingProvider | ||
|
||
FasterKv is a hybrid memory and disk Kv Store, so it can support much larger data storage than memory. | ||
|
||
EasyCaching.FasterKv is a lib that is based on **EasyCaching.Core** and **Microsoft.FASTER.Core**. | ||
|
||
|
||
# How to use ? | ||
|
||
## 1. Install the package via Nuget | ||
|
||
``` | ||
Install-Package EasyCaching.FasterKv | ||
``` | ||
|
||
## 2. Config in Startup class | ||
|
||
```csharp | ||
public class Startup | ||
{ | ||
//... | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddMvc(); | ||
|
||
services.AddEasyCaching(option => | ||
{ | ||
//use fasterkv cache | ||
option.UseFasterKv(config => | ||
{ | ||
// fasterKv must be set SerializerName | ||
config.SerializerName = "msg"; | ||
}) | ||
.WithMessagePack("msg"); | ||
}); | ||
} | ||
} | ||
``` | ||
|
||
### 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,38 @@ | ||
# DefaultMemoryPackSerializer | ||
|
||
DefaultMemoryPackSerializer is is a serializer based on **MemoryPack**. | ||
|
||
# How to Use? | ||
|
||
## Install the package via Nuget | ||
|
||
``` | ||
Install-Package EasyCaching.Serialization.MemoryPack | ||
``` | ||
|
||
## Configuration | ||
|
||
``` | ||
public class Startup | ||
{ | ||
//others... | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddEasyCaching(options => | ||
{ | ||
// with a default name [mempack] | ||
options.WithMemoryPack(); | ||
// with a custom name [myname] | ||
options.WithMemoryPack("myname"); | ||
// add some serialization settings | ||
options.WithMemoryPack(x => | ||
{ | ||
x.StringEncoding = StringEncoding.Utf8; | ||
}, "cus"); | ||
}); | ||
} | ||
} | ||
``` |
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
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
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