diff --git a/README.md b/README.md index b5006aaa..afd0df1a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/AspectCore.md b/docs/AspectCore.md index c38866d2..d81eee84 100644 --- a/docs/AspectCore.md +++ b/docs/AspectCore.md @@ -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 @@ -68,7 +68,7 @@ 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; @@ -86,7 +86,7 @@ public class Program webBuilder.UseStartup(); }) // for aspcectcore - .UseServiceProviderFactory(new AspectCoreServiceProviderFactory()) + .UseServiceContext() ; } ``` @@ -120,12 +120,6 @@ public class Startup } - // for aspectcore - public void ConfigureContainer(IServiceContainer builder) - { - builder.ConfigureAspectCoreInterceptor(); - } - public void Configure(IApplicationBuilder app) { app.UseRouting(); diff --git a/docs/Castle.md b/docs/Castle.md index d50307fc..b9a3be01 100644 --- a/docs/Castle.md +++ b/docs/Castle.md @@ -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 diff --git a/docs/Features.md b/docs/Features.md index e204c488..1972e0ed 100644 --- a/docs/Features.md +++ b/docs/Features.md @@ -23,6 +23,7 @@ 5. SQLite 6. Hybrid 7. Disk + 8. LiteDb - Caching Interceptors 1. AspectCore 2. Castle diff --git a/docs/LiteDB.md b/docs/LiteDB.md new file mode 100644 index 00000000..96a06a9d --- /dev/null +++ b/docs/LiteDB.md @@ -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("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("demo"); + + //RemoveByPrefix + _provider.RemoveByPrefix("prefix"); + + //RemoveByPrefix async + await _provider.RemoveByPrefixAsync("prefix"); + } +} +``` diff --git a/docs/MessagePack.md b/docs/MessagePack.md index 4cbb98c7..4eeed97c 100644 --- a/docs/MessagePack.md +++ b/docs/MessagePack.md @@ -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"); }); } diff --git a/docs/ToDoList.md b/docs/ToDoList.md index 1024f124..bb9d2fd4 100644 --- a/docs/ToDoList.md +++ b/docs/ToDoList.md @@ -9,6 +9,7 @@ - [x] Memcached - [x] Hybrid(Combine local caching and distributed caching) - [x] Disk +- [x] LiteDB - [ ] Others... ## Basic Caching API diff --git a/docs/index.md b/docs/index.md index b55d05b6..986cec3e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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) \ No newline at end of file