Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
catcherwong committed Sep 13, 2020
1 parent 4c1613c commit 8d716b3
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 15 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ EasyCaching is an open source caching library that contains basic usages and som
| EasyCaching.Bus.Redis | ![](https://img.shields.io/nuget/v/EasyCaching.Bus.Redis.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Bus.Redis.svg)
| EasyCaching.Bus.CSRedis | ![](https://img.shields.io/nuget/v/EasyCaching.Bus.CSRedis.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Bus.CSRedis.svg)
| EasyCaching.ResponseCaching | ![](https://img.shields.io/nuget/v/EasyCaching.ResponseCaching.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.ResponseCaching.svg)
| EasyCaching.Disk | ![](https://img.shields.io/nuget/v/EasyCaching.Disk.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Disk.svg)
| EasyCaching.LiteDB | ![](https://img.shields.io/nuget/v/EasyCaching.LiteDB.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.LiteDB.svg)

## Basic Usages

Expand Down
14 changes: 4 additions & 10 deletions docs/AspectCore.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ public class DemoService : IDemoService

## 3. Config in Startup class

There are some difference between .NET Core 2.x and .NET Core 3.0.
There are some difference between .NET Core 2.x and .NET Core 3.1.

### .NET Core 3.0
### .NET Core 3.1

Need to use EasyCaching above version 0.8.0

First, add the use of UseServiceProviderFactory to the Program.

```cs
// for aspcectcore
using AspectCore.Extensions.DependencyInjection;
using AspectCore.Extensions.Hosting;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

Expand All @@ -86,7 +86,7 @@ public class Program
webBuilder.UseStartup<Startup>();
})
// for aspcectcore
.UseServiceProviderFactory(new AspectCoreServiceProviderFactory())
.UseServiceContext()
;
}
```
Expand Down Expand Up @@ -120,12 +120,6 @@ public class Startup

}

// for aspectcore
public void ConfigureContainer(IServiceContainer builder)
{
builder.ConfigureAspectCoreInterceptor();
}

public void Configure(IApplicationBuilder app)
{
app.UseRouting();
Expand Down
4 changes: 2 additions & 2 deletions docs/Castle.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public class DemoService : IDemoService

## 3. Config in Startup class

There are some difference between .NET Core 2.x and .NET Core 3.0.
There are some difference between .NET Core 2.x and .NET Core 3.1.

### .NET Core 3.0
### .NET Core 3.1

Need to use EasyCaching above version 0.8.0

Expand Down
1 change: 1 addition & 0 deletions docs/Features.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
5. SQLite
6. Hybrid
7. Disk
8. LiteDb
- Caching Interceptors
1. AspectCore
2. Castle
Expand Down
91 changes: 91 additions & 0 deletions docs/LiteDB.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# DefaultLiteDBCachingProvider

LiteDB is another choice of local caching, the same as Disk and SQLite.

EasyCaching.LiteDB contains most of caching operations that we can use easily.

EasyCaching.LiteDB is a lib that is based on **EasyCaching.Core** and **LiteDB**.


# How to use ?

## 1. Install the package via Nuget

```
Install-Package EasyCaching.LiteDB
```

## 2. Config in Startup class

```csharp
public class Startup
{
//...
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();

//Important step for SQLite Cache
services.AddEasyCaching(option =>
{
//use sqlite cache
option.UseLiteDB(config =>
{
config.DBConfig = new LiteDBDBOptions { FileName = "s1.ldb" };
});
});
}
}
```

### 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");

//RemoveByPrefix
_provider.RemoveByPrefix("prefix");

//RemoveByPrefix async
await _provider.RemoveByPrefixAsync("prefix");
}
}
```
15 changes: 12 additions & 3 deletions docs/MessagePack.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,20 @@ public void ConfigureServices(IServiceCollection services)
option.WithMessagePack( x =>
{
x.EnableCustomResolver = true;
x.CustomResolvers = CompositeResolver.Create(

// x.CustomResolvers = CompositeResolver.Create(
// // This can solve DateTime time zone problem
// NativeDateTimeResolver.Instance,
// ContractlessStandardResolver.Instance
// );
// due to api changed
x.CustomResolvers = CompositeResolver.Create(new MessagePack.IFormatterResolver[]
{
// This can solve DateTime time zone problem
NativeDateTimeResolver.Instance,
ContractlessStandardResolver.Instance
);
ContractlessStandardResolver.Instance
});
},"mymsgpack");
});
}
Expand Down
1 change: 1 addition & 0 deletions docs/ToDoList.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [x] Memcached
- [x] Hybrid(Combine local caching and distributed caching)
- [x] Disk
- [x] LiteDB
- [ ] Others...

## Basic Caching API
Expand Down
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ EasyCaching is an open source caching library that contains basic usages and som
| EasyCaching.Bus.Redis | ![](https://img.shields.io/nuget/v/EasyCaching.Bus.Redis.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Bus.Redis.svg)
| EasyCaching.Bus.CSRedis | ![](https://img.shields.io/nuget/v/EasyCaching.Bus.CSRedis.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Bus.CSRedis.svg)
| EasyCaching.ResponseCaching | ![](https://img.shields.io/nuget/v/EasyCaching.ResponseCaching.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.ResponseCaching.svg)
| EasyCaching.Disk | ![](https://img.shields.io/nuget/v/EasyCaching.Disk.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Disk.svg)
| EasyCaching.LiteDB | ![](https://img.shields.io/nuget/v/EasyCaching.LiteDB.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.LiteDB.svg)

0 comments on commit 8d716b3

Please sign in to comment.