Skip to content

Commit

Permalink
Merge pull request #75 from dotnetcore/dev
Browse files Browse the repository at this point in the history
Add New Features And Fixed Bugs
  • Loading branch information
catcherwong authored Jan 31, 2019
2 parents a46ce9b + 7598605 commit 6256fa9
Show file tree
Hide file tree
Showing 43 changed files with 5,445 additions and 317 deletions.
7 changes: 7 additions & 0 deletions EasyCaching.sln
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyCaching.UnitTests", "te
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyCaching.PerformanceTests", "test\EasyCaching.PerformanceTests\EasyCaching.PerformanceTests.csproj", "{6EBE36A2-F128-4C63-B90A-B700D8C2F2E8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyCaching.CSRedis", "src\EasyCaching.CSRedis\EasyCaching.CSRedis.csproj", "{6584761E-E51C-408F-BE51-CA0F6269589B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -127,6 +129,10 @@ Global
{6EBE36A2-F128-4C63-B90A-B700D8C2F2E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6EBE36A2-F128-4C63-B90A-B700D8C2F2E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6EBE36A2-F128-4C63-B90A-B700D8C2F2E8}.Release|Any CPU.Build.0 = Release|Any CPU
{6584761E-E51C-408F-BE51-CA0F6269589B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6584761E-E51C-408F-BE51-CA0F6269589B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6584761E-E51C-408F-BE51-CA0F6269589B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6584761E-E51C-408F-BE51-CA0F6269589B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{CE61FAA2-0233-451C-991D-4222ED61C84B} = {A0F5CC7E-155F-4726-8DEB-E966950B3FE9}
Expand All @@ -148,5 +154,6 @@ Global
{76A5C2E3-6525-45A0-9CE7-649F3235A443} = {F88D727A-9F9C-43D9-90B1-D4A02BF8BC98}
{2A8D7103-DF64-47B6-A406-8F8559AF7E7F} = {EBB55F65-7D07-4281-8D5E-7B0CA88E1AD0}
{6EBE36A2-F128-4C63-B90A-B700D8C2F2E8} = {EBB55F65-7D07-4281-8D5E-7B0CA88E1AD0}
{6584761E-E51C-408F-BE51-CA0F6269589B} = {A0F5CC7E-155F-4726-8DEB-E966950B3FE9}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ for:
install:
- ps: cd c:\projects\easycaching\tools\RedisConfigs\3.0.503\
- ps: .\redis-server.exe --service-install --service-name "redis-6379" "..\Basic\master-6379.conf"
- ps: .\redis-server.exe --service-install --service-name "redis-6380" "..\Basic\master-6380.conf"
- ps: .\redis-server.exe --service-install --service-name "redis-6388" "..\Basic\master-6388.conf"
- ps: net start redis-6379
- ps: net start redis-6380
- ps: net start redis-6388
- ps: new-service –Name memcached1 –DisplayName memcached1 –BinaryPathName “c:\projects\easycaching\tools\memcached\memcached.exe -d runservice -m 64 -c 2048 -p 11211” –StartupType Automatic
- ps: new-service –Name memcached2 –DisplayName memcached2 –BinaryPathName “c:\projects\easycaching\tools\memcached\memcached.exe -d runservice -m 64 -c 2048 -p 11212” –StartupType Automatic
- ps: net start memcached1
Expand Down Expand Up @@ -57,6 +61,8 @@ for:

install:
#- sh: sudo apt-get install libevent libevent-deve
- sh: redis-server /home/appveyor/projects/easycaching/tools/RedisConfigs/Basic/master-6388.conf
- sh: redis-server /home/appveyor/projects/easycaching/tools/RedisConfigs/Basic/master-6380.conf
- sh: sudo apt-get install memcached
- sh: sudo memcached -p 11211 -u root -m 64m -d
- sh: sudo memcached -p 11212 -u root -m 64m -d
Expand Down
12 changes: 7 additions & 5 deletions build/releasenotes.props
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<Project>
<PropertyGroup>
<EasyCachingCorePackageNotes>
1. Update BaseRedisOptions.
1. Add IRedisCachingProvider.
</EasyCachingCorePackageNotes>
<EasyCachingMemcachedPackageNotes>
1. Improve Get cached value.
</EasyCachingMemcachedPackageNotes>
<EasyCachingRedisPackageNotes>
1. Update Options.
2. Improve Get cached value.
<EasyCachingRedisPackageNotes>
1. Add Impl of IRedisCachingProvider.
</EasyCachingRedisPackageNotes>
<EasyCachingSQLitePackageNotes>
1. Improve Configuration.
Expand All @@ -21,7 +20,7 @@
1. Improve Configuration.
</EasyCachingHybridPackageNotes>
<EasyCachingAspectCorePackageNotes>
1. Remove Dependency of IEasyCaching.
1. Fixed bug of IConvertible.
</EasyCachingAspectCorePackageNotes>
<EasyCachingCastlePackageNotes>
1. Remove Dependency of IEasyCaching.
Expand All @@ -38,5 +37,8 @@
<EasyCachingProtobufPackageNotes>
1. Improve Configuration.
</EasyCachingProtobufPackageNotes>
<EasyCachingCSRedisPackageNotes>
1. Init.
</EasyCachingCSRedisPackageNotes>
</PropertyGroup>
</Project>
9 changes: 5 additions & 4 deletions build/version.props
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<Project>
<PropertyGroup>
<EasyCachingCorePackageVersion>0.4.5.1</EasyCachingCorePackageVersion>
<EasyCachingCorePackageVersion>0.4.6</EasyCachingCorePackageVersion>
<EasyCachingMemcachedPackageVersion>0.4.5.1</EasyCachingMemcachedPackageVersion>
<EasyCachingRedisPackageVersion>0.4.5.1</EasyCachingRedisPackageVersion>
<EasyCachingRedisPackageVersion>0.4.6</EasyCachingRedisPackageVersion>
<EasyCachingSQLitePackageVersion>0.4.5</EasyCachingSQLitePackageVersion>
<EasyCachingInMemoryPackageVersion>0.4.5.3</EasyCachingInMemoryPackageVersion>
<EasyCachingInMemoryPackageVersion>0.4.6</EasyCachingInMemoryPackageVersion>
<EasyCachingHybridPackageVersion>0.4.5</EasyCachingHybridPackageVersion>
<EasyCachingAspectCorePackageVersion>0.3.2</EasyCachingAspectCorePackageVersion>
<EasyCachingAspectCorePackageVersion>0.3.3</EasyCachingAspectCorePackageVersion>
<EasyCachingCastlePackageVersion>0.3.2</EasyCachingCastlePackageVersion>
<EasyCachingResponseCachingPackageVersion>0.3.0</EasyCachingResponseCachingPackageVersion>
<EasyCachingJsonPackageVersion>0.3.5</EasyCachingJsonPackageVersion>
<EasyCachingMessagePackPackageVersion>0.3.5</EasyCachingMessagePackPackageVersion>
<EasyCachingProtobufPackageVersion>0.3.5</EasyCachingProtobufPackageVersion>
<EasyCachingCSRedisPackageVersion>0.1.0</EasyCachingCSRedisPackageVersion>
</PropertyGroup>
</Project>
129 changes: 71 additions & 58 deletions sample/EasyCaching.Demo.Interceptors/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace EasyCaching.Demo.Interceptors
{
using EasyCaching.Core;
using EasyCaching.Demo.Interceptors.Services;
using EasyCaching.Interceptor.AspectCore;
using EasyCaching.Interceptor.Castle;
Expand All @@ -22,81 +23,93 @@ public Startup(IConfiguration configuration)

public IConfiguration Configuration { get; }

////1.AspectCore
//public IServiceProvider ConfigureServices(IServiceCollection services)
//{
// services.AddScoped<IAspectCoreService, AspectCoreService>();
//1.AspectCore
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddScoped<IAspectCoreService, AspectCoreService>();

// services.AddDefaultInMemoryCache();
// //services.AddDefaultRedisCache(options =>
// //{
// // options.DBConfig = new RedisDBOptions { Configuration = "localhost" };
// //});
services.AddEasyCaching(options=>
{
options.UseInMemory();

// services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
//options.UseRedis(config =>
//{
// config.DBConfig = new RedisDBOptions { Configuration = "localhost" };
//});
});

// //1.1. all default
// return services.ConfigureAspectCoreInterceptor();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

// //1.2. default and customize
// //Action<IServiceContainer> action = x =>
// //{
// // x.AddType<IAspectCoreService, AspectCoreService>();
// //};
//1.1. all default
return services.ConfigureAspectCoreInterceptor();

// //return services.ConfigureAspectCoreInterceptor(action);
//1.2. default and customize
//Action<IServiceContainer> action = x =>
//{
// x.AddType<IAspectCoreService, AspectCoreService>();
//};

// //1.3. all customize
// //Action<IServiceContainer> action = x =>
// //{
// // x.AddType<IDateTimeService, DateTimeService>();
// // x.Configure(config =>
// // {
// // config.Interceptors.AddTyped<EasyCachingInterceptor>(method => typeof(Core.Internal.IEasyCaching).IsAssignableFrom(method.DeclaringType));
// // });
// //};
//return services.ConfigureAspectCoreInterceptor(action);

// //return services.ConfigureAspectCoreInterceptor(action, true);
//}
//1.3. all customize
//Action<IServiceContainer> action = x =>
//{
// x.AddType<IDateTimeService, DateTimeService>();
// x.Configure(config =>
// {
// config.Interceptors.AddTyped<EasyCachingInterceptor>(method => typeof(Core.Internal.IEasyCaching).IsAssignableFrom(method.DeclaringType));
// });
//};

//2. Castle
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddMvc();
//return services.ConfigureAspectCoreInterceptor(action, true);
}

services.AddTransient<ICastleService, CastleService>();
////2. Castle
//public IServiceProvider ConfigureServices(IServiceCollection services)
//{
// services.AddTransient<ICastleService, CastleService>();

services.AddDefaultInMemoryCache();
// services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

// services.AddEasyCaching(options =>
// {
// options.UseInMemory();

//2.1. all default
return services.ConfigureCastleInterceptor();
// //options.UseRedis(config =>
// //{
// // config.DBConfig = new RedisDBOptions { Configuration = "localhost" };
// //});
// });

//2.2. default and customize
//Action<ContainerBuilder> action = x =>
//{
// x.RegisterType<CastleService>().As<ICastleService>();
//};
// //2.1. all default
// return services.ConfigureCastleInterceptor();

//return services.ConfigureCastleInterceptor(action);
// //2.2. default and customize
// //Action<ContainerBuilder> action = x =>
// //{
// // x.RegisterType<CastleService>().As<ICastleService>();
// //};

//2.3. all customize
//Action<ContainerBuilder> action = x =>
//{
// x.RegisterType<DateTimeService>().As<IDateTimeService>();
// //return services.ConfigureCastleInterceptor(action);

// var assembly = Assembly.GetExecutingAssembly();
// x.RegisterType<EasyCachingInterceptor>();
// //2.3. all customize
// //Action<ContainerBuilder> action = x =>
// //{
// // x.RegisterType<DateTimeService>().As<IDateTimeService>();

// x.RegisterAssemblyTypes(assembly)
// .Where(type => typeof(Core.Internal.IEasyCaching).IsAssignableFrom(type) && !type.GetTypeInfo().IsAbstract)
// .AsImplementedInterfaces()
// .InstancePerLifetimeScope()
// .EnableInterfaceInterceptors()
// .InterceptedBy(typeof(EasyCachingInterceptor));
//};
// // var assembly = Assembly.GetExecutingAssembly();
// // x.RegisterType<EasyCachingInterceptor>();

//return services.ConfigureCastleInterceptor(action, true);
}
// // x.RegisterAssemblyTypes(assembly)
// // .Where(type => typeof(Core.Internal.IEasyCaching).IsAssignableFrom(type) && !type.GetTypeInfo().IsAbstract)
// // .AsImplementedInterfaces()
// // .InstancePerLifetimeScope()
// // .EnableInterfaceInterceptors()
// // .InterceptedBy(typeof(EasyCachingInterceptor));
// //};

// //return services.ConfigureCastleInterceptor(action, true);
//}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
Expand Down
72 changes: 3 additions & 69 deletions sample/EasyCaching.Demo.Providers/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,68 +66,7 @@ public void ConfigureServices(IServiceCollection services)

//option.UseMemcached(Configuration);

});

//1. Important step for using InMemory Cache
//services.AddDefaultInMemoryCache();

//services.AddDefaultInMemoryCacheWithFactory();
//services.AddDefaultInMemoryCacheWithFactory("cus");

//services.AddDefaultInMemoryCache(Configuration);

////2. Important step for using Memcached Cache
//services.AddDefaultMemcached(op =>
//{
// op.DBConfig.AddServer("127.0.0.1", 11211);
//});

//services.AddDefaultMemcached(Configuration);

//3. Important step for using Redis Cache
//services.AddDefaultRedisCache(option =>
//{
// option.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379));
// option.DBConfig.Password = "";
//});

//services.AddDefaultRedisCacheWithFactory("redis1",option =>
//{
// option.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379));
// option.DBConfig.Password = "";
//});

//services.AddDefaultRedisCacheWithFactory("redis2", option =>
//{
// option.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6380));
// option.DBConfig.Password = "";
//});

//services.AddDefaultRedisCache(Configuration);

////4. Important step for using SQLite Cache
//services.AddSQLiteCache(option =>
//{
// option.DBConfig = new SQLiteDBOptions { FileName="my.db" };
//});

//services.AddSQLiteCache(Configuration);

////5. Important step for using Hybrid Cache
////5.1. Local Cache
//services.AddDefaultInMemoryCache(x=>
//{
// x.Order = 1;
//});
////5.2 Distributed Cache
//services.AddDefaultRedisCache(option =>
//{
// option.Order = 2;
// option.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379));
// option.DBConfig.Password = "";
//});
////5.3 Hybrid
//services.AddDefaultHybridCache();
});
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
Expand All @@ -139,13 +78,8 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF

loggerFactory.AddConsole(Configuration.GetSection("Logging"));

////2. Important step for using Memcached Cache
//app.UseDefaultMemcached();

////4. Important step for using SQLite Cache
//app.UseSQLiteCache();

//app.UseEasyCaching();
// Important step for using Memcached Cache or SQLite Cache
app.UseEasyCaching();

app.UseMvc();
}
Expand Down
20 changes: 20 additions & 0 deletions src/EasyCaching.CSRedis/Configurations/CSRedisDBOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace EasyCaching.CSRedis
{
using System;
using System.Collections.Generic;

public class CSRedisDBOptions
{
/// <summary>
/// Gets or sets the node rule.
/// </summary>
/// <value>The node rule.</value>
public Func<string, string> NodeRule { get; set; } = null;

/// <summary>
/// Gets or sets the connection strings.
/// </summary>
/// <value>The connection strings.</value>
public List<string> ConnectionStrings { get; set; }
}
}
24 changes: 24 additions & 0 deletions src/EasyCaching.CSRedis/Configurations/EasyCachingCSRedisClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace EasyCaching.CSRedis
{
using System;
using global::CSRedis;

public class EasyCachingCSRedisClient : CSRedisClient
{
private readonly string _name;

public string Name { get { return this._name; } }

public EasyCachingCSRedisClient(string name, string connectionString)
: base(connectionString)
{
this._name = name;
}

public EasyCachingCSRedisClient(string name, Func<string, string> NodeRule, params string[] connectionStrings)
: base(NodeRule, connectionStrings)
{
this._name = name;
}
}
}
Loading

0 comments on commit 6256fa9

Please sign in to comment.