From 86027b68259b0ef56a70782b7e3769b964ebd952 Mon Sep 17 00:00:00 2001 From: catcherwong Date: Tue, 30 Jan 2018 19:43:51 +0800 Subject: [PATCH] :memo: Use readthedocs. --- docs/AspectCore.md | 1 + docs/Castle.md | 1 + docs/Features.md | 1 + docs/Hybrid.md | 1 + docs/In-Memory.md | 73 ++++++++++++++++++++++++ docs/Index.md | 28 +++++++++ docs/Memcached.md | 136 ++++++++++++++++++++++++++++++++++++++++++++ docs/MessagePack.md | 1 + docs/Redis.md | 126 ++++++++++++++++++++++++++++++++++++++++ docs/SQLite.md | 1 + mkdocs.yml | 18 ++++++ 11 files changed, 387 insertions(+) create mode 100644 docs/AspectCore.md create mode 100644 docs/Castle.md create mode 100644 docs/Features.md create mode 100644 docs/Hybrid.md create mode 100644 docs/In-Memory.md create mode 100644 docs/Index.md create mode 100644 docs/Memcached.md create mode 100644 docs/MessagePack.md create mode 100644 docs/Redis.md create mode 100644 docs/SQLite.md create mode 100644 mkdocs.yml diff --git a/docs/AspectCore.md b/docs/AspectCore.md new file mode 100644 index 00000000..f2aeeea3 --- /dev/null +++ b/docs/AspectCore.md @@ -0,0 +1 @@ +coming soon! \ No newline at end of file diff --git a/docs/Castle.md b/docs/Castle.md new file mode 100644 index 00000000..f2aeeea3 --- /dev/null +++ b/docs/Castle.md @@ -0,0 +1 @@ +coming soon! \ No newline at end of file diff --git a/docs/Features.md b/docs/Features.md new file mode 100644 index 00000000..f2aeeea3 --- /dev/null +++ b/docs/Features.md @@ -0,0 +1 @@ +coming soon! \ No newline at end of file diff --git a/docs/Hybrid.md b/docs/Hybrid.md new file mode 100644 index 00000000..f2aeeea3 --- /dev/null +++ b/docs/Hybrid.md @@ -0,0 +1 @@ +coming soon! \ No newline at end of file diff --git a/docs/In-Memory.md b/docs/In-Memory.md new file mode 100644 index 00000000..323d2751 --- /dev/null +++ b/docs/In-Memory.md @@ -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("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"); + } +} +``` diff --git a/docs/Index.md b/docs/Index.md new file mode 100644 index 00000000..527cde70 --- /dev/null +++ b/docs/Index.md @@ -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) \ No newline at end of file diff --git a/docs/Memcached.md b/docs/Memcached.md new file mode 100644 index 00000000..eaa867d8 --- /dev/null +++ b/docs/Memcached.md @@ -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("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"); + + //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 ! diff --git a/docs/MessagePack.md b/docs/MessagePack.md new file mode 100644 index 00000000..f2aeeea3 --- /dev/null +++ b/docs/MessagePack.md @@ -0,0 +1 @@ +coming soon! \ No newline at end of file diff --git a/docs/Redis.md b/docs/Redis.md new file mode 100644 index 00000000..a427f6b8 --- /dev/null +++ b/docs/Redis.md @@ -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("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"); + + //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 ! diff --git a/docs/SQLite.md b/docs/SQLite.md new file mode 100644 index 00000000..f2aeeea3 --- /dev/null +++ b/docs/SQLite.md @@ -0,0 +1 @@ +coming soon! \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 00000000..72cdd87d --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,18 @@ +site_name: EasyCaching +theme: readthedocs +repo_url: https://github.com/catcherwong/EasyCaching + +pages: +- Introduction: index.md +- Features : Features.md +- Caching Provider: + - In-Memory : In-Memory.md + - Redis : Redis.md + - Memcached : Memcached.md + - SQLite : SQLite.md + - Hybird : Hybrid.md +- Caching Interceptor: + - AspectCore : AspectCore.md + - Castle : Castle.md +- Caching Serializer: + - MessagePack : MessagePack.md \ No newline at end of file