diff --git a/.travis.yml b/.travis.yml index f788195c..6fd6a058 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,8 @@ language: csharp - solution: EasyCaching.sln - -sudo: required - -dotnet: 2.1.301 - +dist: xenial +sudo: required +dotnet: 2.2.203 mono: none services: diff --git a/README.md b/README.md index defa09bb..0963906d 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,26 @@ public class Startup //use memory cache that named default option.UseInMemory("default"); + // // use memory cache with your own configuration + // config.UseInMemory(options => + // { + // options.DBConfig = new InMemoryCachingOptions + // { + // // scan time, default value is 60s + // ExpirationScanFrequency = 60, + // // total count of cache items, default value is 10000 + // SizeLimit = 100 + // }; + // // the max random second will be added to cache's expiration, default value is 120 + // options.MaxRdSecond = 120; + // // whether enable logging, default is false + // options.EnableLogging = false; + // // mutex key's alive time(ms), default is 5000 + // options.LockMs = 5000; + // // when mutex key alive, it will sleep some time, default is 300 + // options.SleepMs = 300; + // }, "m2"); + //use redis cache that named redis1 option.UseRedis(config => { diff --git a/build/releasenotes.props b/build/releasenotes.props index 104d8b01..1c351811 100644 --- a/build/releasenotes.props +++ b/build/releasenotes.props @@ -1,59 +1,49 @@ - 1. Add GetExpiration/GetExpirationAsync for caching provider. - 2. IEasyCachingProviderFactory support multi redis provider instances. - 3. IRedisCachingProvider add some string and keys methods. - 4. Interceptor attribute add cache provider + 1. Upgrading dependencies. - 1. Add GetExpiration/GetExpirationAsync for caching provider. + 1. Upgrading dependencies. - 1. Add GetExpiration/GetExpirationAsync for caching provider. - 2. Add some string and keys methods. + 1. Upgrading dependencies. - 1. Add GetExpiration/GetExpirationAsync for caching provider. + 1. Upgrading dependencies. - 1. Add GetExpiration/GetExpirationAsync for caching provider. + 1. Upgrading dependencies. - 1. Add DefaultExpirationForTtlFailed for HybridCachingOptions. - 2. Get distributed cached item's expiration when local cache is null. + 1. Upgrading dependencies. - 1. Update EasyCaching.Core. - 2. Swich caching provider via attribute. - 3. Handle exception when method return null. + 1. Upgrading dependencies. - 1. Update EasyCaching.Core. - 2. Swich caching provider via attribute. - 3. Handle exception when method return null. + 1. Upgrading dependencies. - 1. Update EasyCaching.Core. + 1. Upgrading dependencies. - 1. Update EasyCaching.Core. + 1. Upgrading dependencies. - 1. Update EasyCaching.Core. + 1. Upgrading dependencies. - 1. Update EasyCaching.Core. + 1. Upgrading dependencies. - 1. Add GetExpiration/GetExpirationAsync for caching provider. - 2. Add some string and keys methods. + 1. Upgrading dependencies. - 1. Update EasyCaching.Core. + 1. Upgrading dependencies. - 1. Update EasyCaching.Core. + 1. Upgrading dependencies. diff --git a/build/version.props b/build/version.props index c2a20e97..d2e7dc0a 100644 --- a/build/version.props +++ b/build/version.props @@ -1,20 +1,20 @@ - 0.5.4.2 - 0.5.4.2 - 0.5.4.2 - 0.5.4.2 - 0.5.4.2 - 0.5.4.2 - 0.5.4.2 - 0.5.4.2 - 0.5.4.2 - 0.5.4.2 - 0.5.4.2 - 0.5.4.2 - 0.5.4.2 - 0.5.4.2 - 0.5.4.2 - 0.5.4.2 + 0.5.5 + 0.5.5 + 0.5.5 + 0.5.5 + 0.5.5 + 0.5.5 + 0.5.5 + 0.5.5 + 0.5.5 + 0.5.5 + 0.5.5 + 0.5.5 + 0.5.5 + 0.5.5 + 0.5.5 + 0.5.5 diff --git a/docs/ProviderFactory.md b/docs/ProviderFactory.md index c4be185a..a2b41f5f 100644 --- a/docs/ProviderFactory.md +++ b/docs/ProviderFactory.md @@ -14,6 +14,8 @@ After releasing v0.4.0 of EasyCaching, we can deal with this scenario. This usage of `EasyCachingProviderFactory` is similar with `HttpClientFactory`. +There are two types of providers(`IEasyCachingProvider` and `IRedisCachingProvider`) can use `EasyCachingProviderFactory` to create. + Here use two InMemory caching provders and two Redis caching providers to show. ## 1. Install the packages via Nuget @@ -116,5 +118,21 @@ public class ValuesController : Controller Console.WriteLine($"Type=redis2,Key=named-provider,Value={res},Time:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); return $"cached value : {res}"; } + + // GET api/values/redis3 + [HttpGet] + [Route("redis3")] + public string GetRedis3() + { + var redis1 = factory.GetRedisProvider("redis1"); + var redis2 = factory.GetRedisProvider("redis2"); + + _redis1.StringSet("keyredis1", "val"); + + var res1 = _redis1.StringGet("keyredis1"); + var res2 = _redis2.StringGet("keyredis1"); + + return $"redis1 cached value: {res1}, redis2 cached value : {res2}"; + } } ``` diff --git a/sample/EasyCaching.Demo.Interceptors/EasyCaching.Demo.Interceptors.csproj b/sample/EasyCaching.Demo.Interceptors/EasyCaching.Demo.Interceptors.csproj index e0f4ac68..9912ece2 100644 --- a/sample/EasyCaching.Demo.Interceptors/EasyCaching.Demo.Interceptors.csproj +++ b/sample/EasyCaching.Demo.Interceptors/EasyCaching.Demo.Interceptors.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + netcoreapp2.2 diff --git a/sample/EasyCaching.Demo.Interceptors/Startup.cs b/sample/EasyCaching.Demo.Interceptors/Startup.cs index ef68ddee..1cae6c4e 100644 --- a/sample/EasyCaching.Demo.Interceptors/Startup.cs +++ b/sample/EasyCaching.Demo.Interceptors/Startup.cs @@ -43,7 +43,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services) //options.WithProtobuf(); }); - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); //1.1. all default return services.ConfigureAspectCoreInterceptor(options => options.CacheProviderName = EasyCachingConstValue.DefaultInMemoryName); diff --git a/sample/EasyCaching.Demo.Providers/Controllers/MultiRedisController.cs b/sample/EasyCaching.Demo.Providers/Controllers/MultiRedisController.cs new file mode 100644 index 00000000..38a32554 --- /dev/null +++ b/sample/EasyCaching.Demo.Providers/Controllers/MultiRedisController.cs @@ -0,0 +1,30 @@ +namespace EasyCaching.Demo.Providers.Controllers +{ + using EasyCaching.Core; + using Microsoft.AspNetCore.Mvc; + + [Route("api/mredis")] + public class MultiRedisController : Controller + { + private readonly IRedisCachingProvider _redis1; + private readonly IRedisCachingProvider _redis2; + + public MultiRedisController(IEasyCachingProviderFactory factory) + { + this._redis1 = factory.GetRedisProvider("redis1"); + this._redis2 = factory.GetRedisProvider("redis2"); + } + + // GET api/mredis + [HttpGet] + public string Get() + { + _redis1.StringSet("keyredis1", "val"); + + var res1 = _redis1.StringGet("keyredis1"); + var res2 = _redis2.StringGet("keyredis1"); + + return $"redis1 cached value: {res1}, redis2 cached value : {res2}"; + } + } +} diff --git a/sample/EasyCaching.Demo.Providers/EasyCaching.Demo.Providers.csproj b/sample/EasyCaching.Demo.Providers/EasyCaching.Demo.Providers.csproj index 34371c8c..08e8aaea 100644 --- a/sample/EasyCaching.Demo.Providers/EasyCaching.Demo.Providers.csproj +++ b/sample/EasyCaching.Demo.Providers/EasyCaching.Demo.Providers.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + netcoreapp2.2 diff --git a/sample/EasyCaching.Demo.Providers/Startup.cs b/sample/EasyCaching.Demo.Providers/Startup.cs index 4c41d77d..dbd8604f 100644 --- a/sample/EasyCaching.Demo.Providers/Startup.cs +++ b/sample/EasyCaching.Demo.Providers/Startup.cs @@ -28,7 +28,7 @@ public Startup(IConfiguration configuration) public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); //new configuration services.AddEasyCaching(option=> @@ -77,7 +77,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF app.UseDeveloperExceptionPage(); } - loggerFactory.AddConsole(Configuration.GetSection("Logging")); + //loggerFactory.AddConsole(Configuration.GetSection("Logging")); // Important step for using Memcached Cache or SQLite Cache app.UseEasyCaching(); diff --git a/sample/EasyCaching.Demo.ResponseCaching/EasyCaching.Demo.ResponseCaching.csproj b/sample/EasyCaching.Demo.ResponseCaching/EasyCaching.Demo.ResponseCaching.csproj index d55aa156..9489d7f0 100644 --- a/sample/EasyCaching.Demo.ResponseCaching/EasyCaching.Demo.ResponseCaching.csproj +++ b/sample/EasyCaching.Demo.ResponseCaching/EasyCaching.Demo.ResponseCaching.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + netcoreapp2.2 diff --git a/sample/EasyCaching.Demo.ResponseCaching/Startup.cs b/sample/EasyCaching.Demo.ResponseCaching/Startup.cs index b9c8eba2..ad67860c 100644 --- a/sample/EasyCaching.Demo.ResponseCaching/Startup.cs +++ b/sample/EasyCaching.Demo.ResponseCaching/Startup.cs @@ -21,7 +21,7 @@ public Startup(IConfiguration configuration) public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddEasyCaching(x => { x.UseInMemory(); }); services.AddEasyCachingResponseCaching(EasyCachingConstValue.DefaultInMemoryName); diff --git a/src/EasyCaching.Bus.CSRedis/EasyCaching.Bus.CSRedis.csproj b/src/EasyCaching.Bus.CSRedis/EasyCaching.Bus.CSRedis.csproj index 2a1831f5..2f2d10af 100644 --- a/src/EasyCaching.Bus.CSRedis/EasyCaching.Bus.CSRedis.csproj +++ b/src/EasyCaching.Bus.CSRedis/EasyCaching.Bus.CSRedis.csproj @@ -26,8 +26,7 @@ - - + diff --git a/src/EasyCaching.Bus.RabbitMQ/EasyCaching.Bus.RabbitMQ.csproj b/src/EasyCaching.Bus.RabbitMQ/EasyCaching.Bus.RabbitMQ.csproj index 9898bc22..2df0a2e4 100644 --- a/src/EasyCaching.Bus.RabbitMQ/EasyCaching.Bus.RabbitMQ.csproj +++ b/src/EasyCaching.Bus.RabbitMQ/EasyCaching.Bus.RabbitMQ.csproj @@ -29,9 +29,8 @@ - - - + + diff --git a/src/EasyCaching.Bus.Redis/EasyCaching.Bus.Redis.csproj b/src/EasyCaching.Bus.Redis/EasyCaching.Bus.Redis.csproj index b034f310..a9e2e243 100644 --- a/src/EasyCaching.Bus.Redis/EasyCaching.Bus.Redis.csproj +++ b/src/EasyCaching.Bus.Redis/EasyCaching.Bus.Redis.csproj @@ -26,8 +26,7 @@ - - + diff --git a/src/EasyCaching.CSRedis/EasyCaching.CSRedis.csproj b/src/EasyCaching.CSRedis/EasyCaching.CSRedis.csproj index 9a0e6de0..8630aa45 100644 --- a/src/EasyCaching.CSRedis/EasyCaching.CSRedis.csproj +++ b/src/EasyCaching.CSRedis/EasyCaching.CSRedis.csproj @@ -26,8 +26,7 @@ - - + diff --git a/src/EasyCaching.Core/Configurations/EasyCachingOptions.cs b/src/EasyCaching.Core/Configurations/EasyCachingOptions.cs index 7dc642b2..4a972435 100644 --- a/src/EasyCaching.Core/Configurations/EasyCachingOptions.cs +++ b/src/EasyCaching.Core/Configurations/EasyCachingOptions.cs @@ -1,6 +1,5 @@ namespace EasyCaching.Core.Configurations { - using System; using System.Collections.Generic; /// @@ -32,10 +31,5 @@ public void RegisterExtension(IEasyCachingOptionsExtension extension) Extensions.Add(extension); } - - public void UseCSRedis(Func p, string v) - { - throw new NotImplementedException(); - } } } diff --git a/src/EasyCaching.Core/EasyCaching.Core.csproj b/src/EasyCaching.Core/EasyCaching.Core.csproj index f414a230..3f3e1ed3 100644 --- a/src/EasyCaching.Core/EasyCaching.Core.csproj +++ b/src/EasyCaching.Core/EasyCaching.Core.csproj @@ -36,8 +36,10 @@ - - + + + + diff --git a/src/EasyCaching.HybridCache/EasyCaching.HybridCache.csproj b/src/EasyCaching.HybridCache/EasyCaching.HybridCache.csproj index 271ece1f..526ba49f 100644 --- a/src/EasyCaching.HybridCache/EasyCaching.HybridCache.csproj +++ b/src/EasyCaching.HybridCache/EasyCaching.HybridCache.csproj @@ -28,10 +28,7 @@ - - - - + diff --git a/src/EasyCaching.InMemory/EasyCaching.InMemory.csproj b/src/EasyCaching.InMemory/EasyCaching.InMemory.csproj index bea337c4..decf6910 100644 --- a/src/EasyCaching.InMemory/EasyCaching.InMemory.csproj +++ b/src/EasyCaching.InMemory/EasyCaching.InMemory.csproj @@ -28,9 +28,7 @@ - - - + diff --git a/src/EasyCaching.Interceptor.AspectCore/EasyCaching.Interceptor.AspectCore.csproj b/src/EasyCaching.Interceptor.AspectCore/EasyCaching.Interceptor.AspectCore.csproj index 6d299b57..41b15135 100644 --- a/src/EasyCaching.Interceptor.AspectCore/EasyCaching.Interceptor.AspectCore.csproj +++ b/src/EasyCaching.Interceptor.AspectCore/EasyCaching.Interceptor.AspectCore.csproj @@ -29,8 +29,7 @@ - - - + + diff --git a/src/EasyCaching.Interceptor.Castle/EasyCaching.Interceptor.Castle.csproj b/src/EasyCaching.Interceptor.Castle/EasyCaching.Interceptor.Castle.csproj index b5c76443..e90942c5 100644 --- a/src/EasyCaching.Interceptor.Castle/EasyCaching.Interceptor.Castle.csproj +++ b/src/EasyCaching.Interceptor.Castle/EasyCaching.Interceptor.Castle.csproj @@ -29,11 +29,10 @@ - + - - - - + + + diff --git a/src/EasyCaching.Memcached/EasyCaching.Memcached.csproj b/src/EasyCaching.Memcached/EasyCaching.Memcached.csproj index 38336de3..06b46b56 100644 --- a/src/EasyCaching.Memcached/EasyCaching.Memcached.csproj +++ b/src/EasyCaching.Memcached/EasyCaching.Memcached.csproj @@ -29,7 +29,7 @@ - + diff --git a/src/EasyCaching.Redis/EasyCaching.Redis.csproj b/src/EasyCaching.Redis/EasyCaching.Redis.csproj index 029724dd..93dea6df 100644 --- a/src/EasyCaching.Redis/EasyCaching.Redis.csproj +++ b/src/EasyCaching.Redis/EasyCaching.Redis.csproj @@ -26,8 +26,7 @@ - - + diff --git a/src/EasyCaching.ResponseCaching/EasyCaching.ResponseCaching.csproj b/src/EasyCaching.ResponseCaching/EasyCaching.ResponseCaching.csproj index 499f9509..b48d8e02 100644 --- a/src/EasyCaching.ResponseCaching/EasyCaching.ResponseCaching.csproj +++ b/src/EasyCaching.ResponseCaching/EasyCaching.ResponseCaching.csproj @@ -29,6 +29,6 @@ - + diff --git a/src/EasyCaching.SQLite/EasyCaching.SQLite.csproj b/src/EasyCaching.SQLite/EasyCaching.SQLite.csproj index 64c8f500..7a20e78a 100644 --- a/src/EasyCaching.SQLite/EasyCaching.SQLite.csproj +++ b/src/EasyCaching.SQLite/EasyCaching.SQLite.csproj @@ -29,11 +29,9 @@ - - - - - + + + diff --git a/src/EasyCaching.Serialization.Json/EasyCaching.Serialization.Json.csproj b/src/EasyCaching.Serialization.Json/EasyCaching.Serialization.Json.csproj index fdafa7b7..1ba7f982 100644 --- a/src/EasyCaching.Serialization.Json/EasyCaching.Serialization.Json.csproj +++ b/src/EasyCaching.Serialization.Json/EasyCaching.Serialization.Json.csproj @@ -30,8 +30,7 @@ - - + diff --git a/src/EasyCaching.Serialization.MessagePack/EasyCaching.Serialization.MessagePack.csproj b/src/EasyCaching.Serialization.MessagePack/EasyCaching.Serialization.MessagePack.csproj index c70b5182..050e9906 100644 --- a/src/EasyCaching.Serialization.MessagePack/EasyCaching.Serialization.MessagePack.csproj +++ b/src/EasyCaching.Serialization.MessagePack/EasyCaching.Serialization.MessagePack.csproj @@ -29,8 +29,7 @@ - - + diff --git a/src/EasyCaching.Serialization.Protobuf/EasyCaching.Serialization.Protobuf.csproj b/src/EasyCaching.Serialization.Protobuf/EasyCaching.Serialization.Protobuf.csproj index 75b53130..6ea03e9c 100644 --- a/src/EasyCaching.Serialization.Protobuf/EasyCaching.Serialization.Protobuf.csproj +++ b/src/EasyCaching.Serialization.Protobuf/EasyCaching.Serialization.Protobuf.csproj @@ -29,8 +29,7 @@ - - + diff --git a/test/EasyCaching.PerformanceTests/EasyCaching.PerformanceTests.csproj b/test/EasyCaching.PerformanceTests/EasyCaching.PerformanceTests.csproj index 6a29166c..488d9ea2 100644 --- a/test/EasyCaching.PerformanceTests/EasyCaching.PerformanceTests.csproj +++ b/test/EasyCaching.PerformanceTests/EasyCaching.PerformanceTests.csproj @@ -2,13 +2,13 @@ Exe - netcoreapp2.1 + netcoreapp2.2 - - + + diff --git a/test/EasyCaching.UnitTests/EasyCaching.UnitTests.csproj b/test/EasyCaching.UnitTests/EasyCaching.UnitTests.csproj index 0858e4d6..93f0f51a 100644 --- a/test/EasyCaching.UnitTests/EasyCaching.UnitTests.csproj +++ b/test/EasyCaching.UnitTests/EasyCaching.UnitTests.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + netcoreapp2.2 false @@ -11,9 +11,9 @@ - - - + + +