Skip to content

Commit 6256fa9

Browse files
authored
Merge pull request #75 from dotnetcore/dev
Add New Features And Fixed Bugs
2 parents a46ce9b + 7598605 commit 6256fa9

File tree

43 files changed

+5445
-317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+5445
-317
lines changed

EasyCaching.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyCaching.UnitTests", "te
4545
EndProject
4646
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyCaching.PerformanceTests", "test\EasyCaching.PerformanceTests\EasyCaching.PerformanceTests.csproj", "{6EBE36A2-F128-4C63-B90A-B700D8C2F2E8}"
4747
EndProject
48+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyCaching.CSRedis", "src\EasyCaching.CSRedis\EasyCaching.CSRedis.csproj", "{6584761E-E51C-408F-BE51-CA0F6269589B}"
49+
EndProject
4850
Global
4951
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5052
Debug|Any CPU = Debug|Any CPU
@@ -127,6 +129,10 @@ Global
127129
{6EBE36A2-F128-4C63-B90A-B700D8C2F2E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
128130
{6EBE36A2-F128-4C63-B90A-B700D8C2F2E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
129131
{6EBE36A2-F128-4C63-B90A-B700D8C2F2E8}.Release|Any CPU.Build.0 = Release|Any CPU
132+
{6584761E-E51C-408F-BE51-CA0F6269589B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
133+
{6584761E-E51C-408F-BE51-CA0F6269589B}.Debug|Any CPU.Build.0 = Debug|Any CPU
134+
{6584761E-E51C-408F-BE51-CA0F6269589B}.Release|Any CPU.ActiveCfg = Release|Any CPU
135+
{6584761E-E51C-408F-BE51-CA0F6269589B}.Release|Any CPU.Build.0 = Release|Any CPU
130136
EndGlobalSection
131137
GlobalSection(NestedProjects) = preSolution
132138
{CE61FAA2-0233-451C-991D-4222ED61C84B} = {A0F5CC7E-155F-4726-8DEB-E966950B3FE9}
@@ -148,5 +154,6 @@ Global
148154
{76A5C2E3-6525-45A0-9CE7-649F3235A443} = {F88D727A-9F9C-43D9-90B1-D4A02BF8BC98}
149155
{2A8D7103-DF64-47B6-A406-8F8559AF7E7F} = {EBB55F65-7D07-4281-8D5E-7B0CA88E1AD0}
150156
{6EBE36A2-F128-4C63-B90A-B700D8C2F2E8} = {EBB55F65-7D07-4281-8D5E-7B0CA88E1AD0}
157+
{6584761E-E51C-408F-BE51-CA0F6269589B} = {A0F5CC7E-155F-4726-8DEB-E966950B3FE9}
151158
EndGlobalSection
152159
EndGlobal

appveyor.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ for:
2929
install:
3030
- ps: cd c:\projects\easycaching\tools\RedisConfigs\3.0.503\
3131
- ps: .\redis-server.exe --service-install --service-name "redis-6379" "..\Basic\master-6379.conf"
32+
- ps: .\redis-server.exe --service-install --service-name "redis-6380" "..\Basic\master-6380.conf"
33+
- ps: .\redis-server.exe --service-install --service-name "redis-6388" "..\Basic\master-6388.conf"
3234
- ps: net start redis-6379
35+
- ps: net start redis-6380
36+
- ps: net start redis-6388
3337
- 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
3438
- 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
3539
- ps: net start memcached1
@@ -57,6 +61,8 @@ for:
5761

5862
install:
5963
#- sh: sudo apt-get install libevent libevent-deve
64+
- sh: redis-server /home/appveyor/projects/easycaching/tools/RedisConfigs/Basic/master-6388.conf
65+
- sh: redis-server /home/appveyor/projects/easycaching/tools/RedisConfigs/Basic/master-6380.conf
6066
- sh: sudo apt-get install memcached
6167
- sh: sudo memcached -p 11211 -u root -m 64m -d
6268
- sh: sudo memcached -p 11212 -u root -m 64m -d

build/releasenotes.props

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<Project>
22
<PropertyGroup>
33
<EasyCachingCorePackageNotes>
4-
1. Update BaseRedisOptions.
4+
1. Add IRedisCachingProvider.
55
</EasyCachingCorePackageNotes>
66
<EasyCachingMemcachedPackageNotes>
77
1. Improve Get cached value.
88
</EasyCachingMemcachedPackageNotes>
9-
<EasyCachingRedisPackageNotes>
10-
1. Update Options.
11-
2. Improve Get cached value.
9+
<EasyCachingRedisPackageNotes>
10+
1. Add Impl of IRedisCachingProvider.
1211
</EasyCachingRedisPackageNotes>
1312
<EasyCachingSQLitePackageNotes>
1413
1. Improve Configuration.
@@ -21,7 +20,7 @@
2120
1. Improve Configuration.
2221
</EasyCachingHybridPackageNotes>
2322
<EasyCachingAspectCorePackageNotes>
24-
1. Remove Dependency of IEasyCaching.
23+
1. Fixed bug of IConvertible.
2524
</EasyCachingAspectCorePackageNotes>
2625
<EasyCachingCastlePackageNotes>
2726
1. Remove Dependency of IEasyCaching.
@@ -38,5 +37,8 @@
3837
<EasyCachingProtobufPackageNotes>
3938
1. Improve Configuration.
4039
</EasyCachingProtobufPackageNotes>
40+
<EasyCachingCSRedisPackageNotes>
41+
1. Init.
42+
</EasyCachingCSRedisPackageNotes>
4143
</PropertyGroup>
4244
</Project>

build/version.props

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<Project>
22
<PropertyGroup>
3-
<EasyCachingCorePackageVersion>0.4.5.1</EasyCachingCorePackageVersion>
3+
<EasyCachingCorePackageVersion>0.4.6</EasyCachingCorePackageVersion>
44
<EasyCachingMemcachedPackageVersion>0.4.5.1</EasyCachingMemcachedPackageVersion>
5-
<EasyCachingRedisPackageVersion>0.4.5.1</EasyCachingRedisPackageVersion>
5+
<EasyCachingRedisPackageVersion>0.4.6</EasyCachingRedisPackageVersion>
66
<EasyCachingSQLitePackageVersion>0.4.5</EasyCachingSQLitePackageVersion>
7-
<EasyCachingInMemoryPackageVersion>0.4.5.3</EasyCachingInMemoryPackageVersion>
7+
<EasyCachingInMemoryPackageVersion>0.4.6</EasyCachingInMemoryPackageVersion>
88
<EasyCachingHybridPackageVersion>0.4.5</EasyCachingHybridPackageVersion>
9-
<EasyCachingAspectCorePackageVersion>0.3.2</EasyCachingAspectCorePackageVersion>
9+
<EasyCachingAspectCorePackageVersion>0.3.3</EasyCachingAspectCorePackageVersion>
1010
<EasyCachingCastlePackageVersion>0.3.2</EasyCachingCastlePackageVersion>
1111
<EasyCachingResponseCachingPackageVersion>0.3.0</EasyCachingResponseCachingPackageVersion>
1212
<EasyCachingJsonPackageVersion>0.3.5</EasyCachingJsonPackageVersion>
1313
<EasyCachingMessagePackPackageVersion>0.3.5</EasyCachingMessagePackPackageVersion>
1414
<EasyCachingProtobufPackageVersion>0.3.5</EasyCachingProtobufPackageVersion>
15+
<EasyCachingCSRedisPackageVersion>0.1.0</EasyCachingCSRedisPackageVersion>
1516
</PropertyGroup>
1617
</Project>

sample/EasyCaching.Demo.Interceptors/Startup.cs

Lines changed: 71 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace EasyCaching.Demo.Interceptors
22
{
3+
using EasyCaching.Core;
34
using EasyCaching.Demo.Interceptors.Services;
45
using EasyCaching.Interceptor.AspectCore;
56
using EasyCaching.Interceptor.Castle;
@@ -22,81 +23,93 @@ public Startup(IConfiguration configuration)
2223

2324
public IConfiguration Configuration { get; }
2425

25-
////1.AspectCore
26-
//public IServiceProvider ConfigureServices(IServiceCollection services)
27-
//{
28-
// services.AddScoped<IAspectCoreService, AspectCoreService>();
26+
//1.AspectCore
27+
public IServiceProvider ConfigureServices(IServiceCollection services)
28+
{
29+
services.AddScoped<IAspectCoreService, AspectCoreService>();
2930

30-
// services.AddDefaultInMemoryCache();
31-
// //services.AddDefaultRedisCache(options =>
32-
// //{
33-
// // options.DBConfig = new RedisDBOptions { Configuration = "localhost" };
34-
// //});
31+
services.AddEasyCaching(options=>
32+
{
33+
options.UseInMemory();
3534

36-
// services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
35+
//options.UseRedis(config =>
36+
//{
37+
// config.DBConfig = new RedisDBOptions { Configuration = "localhost" };
38+
//});
39+
});
3740

38-
// //1.1. all default
39-
// return services.ConfigureAspectCoreInterceptor();
41+
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
4042

41-
// //1.2. default and customize
42-
// //Action<IServiceContainer> action = x =>
43-
// //{
44-
// // x.AddType<IAspectCoreService, AspectCoreService>();
45-
// //};
43+
//1.1. all default
44+
return services.ConfigureAspectCoreInterceptor();
4645

47-
// //return services.ConfigureAspectCoreInterceptor(action);
46+
//1.2. default and customize
47+
//Action<IServiceContainer> action = x =>
48+
//{
49+
// x.AddType<IAspectCoreService, AspectCoreService>();
50+
//};
4851

49-
// //1.3. all customize
50-
// //Action<IServiceContainer> action = x =>
51-
// //{
52-
// // x.AddType<IDateTimeService, DateTimeService>();
53-
// // x.Configure(config =>
54-
// // {
55-
// // config.Interceptors.AddTyped<EasyCachingInterceptor>(method => typeof(Core.Internal.IEasyCaching).IsAssignableFrom(method.DeclaringType));
56-
// // });
57-
// //};
52+
//return services.ConfigureAspectCoreInterceptor(action);
5853

59-
// //return services.ConfigureAspectCoreInterceptor(action, true);
60-
//}
54+
//1.3. all customize
55+
//Action<IServiceContainer> action = x =>
56+
//{
57+
// x.AddType<IDateTimeService, DateTimeService>();
58+
// x.Configure(config =>
59+
// {
60+
// config.Interceptors.AddTyped<EasyCachingInterceptor>(method => typeof(Core.Internal.IEasyCaching).IsAssignableFrom(method.DeclaringType));
61+
// });
62+
//};
6163

62-
//2. Castle
63-
public IServiceProvider ConfigureServices(IServiceCollection services)
64-
{
65-
services.AddMvc();
64+
//return services.ConfigureAspectCoreInterceptor(action, true);
65+
}
6666

67-
services.AddTransient<ICastleService, CastleService>();
67+
////2. Castle
68+
//public IServiceProvider ConfigureServices(IServiceCollection services)
69+
//{
70+
// services.AddTransient<ICastleService, CastleService>();
6871

69-
services.AddDefaultInMemoryCache();
72+
// services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
73+
74+
// services.AddEasyCaching(options =>
75+
// {
76+
// options.UseInMemory();
7077

71-
//2.1. all default
72-
return services.ConfigureCastleInterceptor();
78+
// //options.UseRedis(config =>
79+
// //{
80+
// // config.DBConfig = new RedisDBOptions { Configuration = "localhost" };
81+
// //});
82+
// });
7383

74-
//2.2. default and customize
75-
//Action<ContainerBuilder> action = x =>
76-
//{
77-
// x.RegisterType<CastleService>().As<ICastleService>();
78-
//};
84+
// //2.1. all default
85+
// return services.ConfigureCastleInterceptor();
7986

80-
//return services.ConfigureCastleInterceptor(action);
87+
// //2.2. default and customize
88+
// //Action<ContainerBuilder> action = x =>
89+
// //{
90+
// // x.RegisterType<CastleService>().As<ICastleService>();
91+
// //};
8192

82-
//2.3. all customize
83-
//Action<ContainerBuilder> action = x =>
84-
//{
85-
// x.RegisterType<DateTimeService>().As<IDateTimeService>();
93+
// //return services.ConfigureCastleInterceptor(action);
8694

87-
// var assembly = Assembly.GetExecutingAssembly();
88-
// x.RegisterType<EasyCachingInterceptor>();
95+
// //2.3. all customize
96+
// //Action<ContainerBuilder> action = x =>
97+
// //{
98+
// // x.RegisterType<DateTimeService>().As<IDateTimeService>();
8999

90-
// x.RegisterAssemblyTypes(assembly)
91-
// .Where(type => typeof(Core.Internal.IEasyCaching).IsAssignableFrom(type) && !type.GetTypeInfo().IsAbstract)
92-
// .AsImplementedInterfaces()
93-
// .InstancePerLifetimeScope()
94-
// .EnableInterfaceInterceptors()
95-
// .InterceptedBy(typeof(EasyCachingInterceptor));
96-
//};
100+
// // var assembly = Assembly.GetExecutingAssembly();
101+
// // x.RegisterType<EasyCachingInterceptor>();
97102

98-
//return services.ConfigureCastleInterceptor(action, true);
99-
}
103+
// // x.RegisterAssemblyTypes(assembly)
104+
// // .Where(type => typeof(Core.Internal.IEasyCaching).IsAssignableFrom(type) && !type.GetTypeInfo().IsAbstract)
105+
// // .AsImplementedInterfaces()
106+
// // .InstancePerLifetimeScope()
107+
// // .EnableInterfaceInterceptors()
108+
// // .InterceptedBy(typeof(EasyCachingInterceptor));
109+
// //};
110+
111+
// //return services.ConfigureCastleInterceptor(action, true);
112+
//}
100113

101114
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
102115
{

sample/EasyCaching.Demo.Providers/Startup.cs

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -66,68 +66,7 @@ public void ConfigureServices(IServiceCollection services)
6666

6767
//option.UseMemcached(Configuration);
6868

69-
});
70-
71-
//1. Important step for using InMemory Cache
72-
//services.AddDefaultInMemoryCache();
73-
74-
//services.AddDefaultInMemoryCacheWithFactory();
75-
//services.AddDefaultInMemoryCacheWithFactory("cus");
76-
77-
//services.AddDefaultInMemoryCache(Configuration);
78-
79-
////2. Important step for using Memcached Cache
80-
//services.AddDefaultMemcached(op =>
81-
//{
82-
// op.DBConfig.AddServer("127.0.0.1", 11211);
83-
//});
84-
85-
//services.AddDefaultMemcached(Configuration);
86-
87-
//3. Important step for using Redis Cache
88-
//services.AddDefaultRedisCache(option =>
89-
//{
90-
// option.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379));
91-
// option.DBConfig.Password = "";
92-
//});
93-
94-
//services.AddDefaultRedisCacheWithFactory("redis1",option =>
95-
//{
96-
// option.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379));
97-
// option.DBConfig.Password = "";
98-
//});
99-
100-
//services.AddDefaultRedisCacheWithFactory("redis2", option =>
101-
//{
102-
// option.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6380));
103-
// option.DBConfig.Password = "";
104-
//});
105-
106-
//services.AddDefaultRedisCache(Configuration);
107-
108-
////4. Important step for using SQLite Cache
109-
//services.AddSQLiteCache(option =>
110-
//{
111-
// option.DBConfig = new SQLiteDBOptions { FileName="my.db" };
112-
//});
113-
114-
//services.AddSQLiteCache(Configuration);
115-
116-
////5. Important step for using Hybrid Cache
117-
////5.1. Local Cache
118-
//services.AddDefaultInMemoryCache(x=>
119-
//{
120-
// x.Order = 1;
121-
//});
122-
////5.2 Distributed Cache
123-
//services.AddDefaultRedisCache(option =>
124-
//{
125-
// option.Order = 2;
126-
// option.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379));
127-
// option.DBConfig.Password = "";
128-
//});
129-
////5.3 Hybrid
130-
//services.AddDefaultHybridCache();
69+
});
13170
}
13271

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

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

142-
////2. Important step for using Memcached Cache
143-
//app.UseDefaultMemcached();
144-
145-
////4. Important step for using SQLite Cache
146-
//app.UseSQLiteCache();
147-
148-
//app.UseEasyCaching();
81+
// Important step for using Memcached Cache or SQLite Cache
82+
app.UseEasyCaching();
14983

15084
app.UseMvc();
15185
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace EasyCaching.CSRedis
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
6+
public class CSRedisDBOptions
7+
{
8+
/// <summary>
9+
/// Gets or sets the node rule.
10+
/// </summary>
11+
/// <value>The node rule.</value>
12+
public Func<string, string> NodeRule { get; set; } = null;
13+
14+
/// <summary>
15+
/// Gets or sets the connection strings.
16+
/// </summary>
17+
/// <value>The connection strings.</value>
18+
public List<string> ConnectionStrings { get; set; }
19+
}
20+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace EasyCaching.CSRedis
2+
{
3+
using System;
4+
using global::CSRedis;
5+
6+
public class EasyCachingCSRedisClient : CSRedisClient
7+
{
8+
private readonly string _name;
9+
10+
public string Name { get { return this._name; } }
11+
12+
public EasyCachingCSRedisClient(string name, string connectionString)
13+
: base(connectionString)
14+
{
15+
this._name = name;
16+
}
17+
18+
public EasyCachingCSRedisClient(string name, Func<string, string> NodeRule, params string[] connectionStrings)
19+
: base(NodeRule, connectionStrings)
20+
{
21+
this._name = name;
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)