Skip to content

Commit 94771e4

Browse files
authored
Merge pull request #36 from dotnetcore/dev
Refactoring And Add new API
2 parents c928aae + f0d5d9b commit 94771e4

35 files changed

+914
-705
lines changed

sample/EasyCaching.Demo.Providers/Startup.cs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,35 +47,21 @@ public void ConfigureServices(IServiceCollection services)
4747

4848
////5. Important step for using Hybrid Cache
4949
////5.1. Local Cache
50-
//services.AddDefaultInMemoryCacheForHybrid();
50+
//services.AddDefaultInMemoryCache(x=>
51+
//{
52+
// x.Order = 1;
53+
//});
5154
////5.2 Distributed Cache
52-
//services.AddDefaultRedisCacheForHybrid(option =>
55+
//services.AddDefaultRedisCache(option =>
5356
//{
5457
// option.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379));
5558
// option.Password = "";
59+
//}, x=>
60+
//{
61+
// x.Order = 2;//this value should greater than local caching provider
5662
//});
5763
////5.3 Hybrid
5864
//services.AddDefaultHybridCache();
59-
////5.4 Singleton
60-
//services.AddSingleton(factory =>
61-
//{
62-
// Func<string, IEasyCachingProvider> accesor = key =>
63-
// {
64-
// if (key.Equals(HybridCachingKeyType.LocalKey))
65-
// {
66-
// return factory.GetService<DefaultInMemoryCachingProvider>();
67-
// }
68-
// else if (key.Equals(HybridCachingKeyType.DistributedKey))
69-
// {
70-
// return factory.GetService<DefaultRedisCachingProvider>();
71-
// }
72-
// else
73-
// {
74-
// throw new Exception();
75-
// }
76-
// };
77-
// return accesor;
78-
//});
7965
}
8066

8167
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace EasyCaching.Core
2+
{
3+
/// <summary>
4+
/// Caching provider type.
5+
/// </summary>
6+
public enum CachingProviderType
7+
{
8+
InMemory,
9+
Memcached,
10+
Redis,
11+
SQLite,
12+
Ext1,
13+
Ext2
14+
}
15+
}

src/EasyCaching.Core/EasyCaching.Core.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<Owners>Catcher Wong</Owners>
66
<Authors>Catcher Wong</Authors>
7-
<Version>0.2.0</Version>
7+
<Version>0.2.1</Version>
88
<Description>
99
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!
1010
</Description>
@@ -15,7 +15,8 @@
1515
<ProjectUrl>https://github.com/dotnetcore/EasyCaching</ProjectUrl>
1616
<PackageIconUrl>https://raw.githubusercontent.com/dotnetcore/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
1717
<PackageReleaseNotes>
18-
Add GetCount and Flush for providers.
18+
1. Add FlushAsync for providers.
19+
2. Add BaseProviderOptions.
1920
</PackageReleaseNotes>
2021
</PropertyGroup>
2122

src/EasyCaching.Core/EasyCachingType.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/EasyCaching.Core/IEasyCachingProvider.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,23 @@ public interface IEasyCachingProvider
207207
/// </summary>
208208
/// <returns>The async.</returns>
209209
Task FlushAsync();
210+
211+
/// <summary>
212+
/// Gets the order.
213+
/// </summary>
214+
/// <value>The order.</value>
215+
int Order { get; }
216+
217+
/// <summary>
218+
/// Gets the max rd second.
219+
/// </summary>
220+
/// <value>The max random second.</value>
221+
int MaxRdSecond { get; }
222+
223+
/// <summary>
224+
/// Gets the type of the caching provider.
225+
/// </summary>
226+
/// <value>The type of the caching provider.</value>
227+
CachingProviderType CachingProviderType { get; }
210228
}
211229
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
namespace EasyCaching.Core.Internal
2+
{
3+
using System;
4+
5+
/// <summary>
6+
/// Base provider options.
7+
/// </summary>
8+
public class BaseProviderOptions
9+
{
10+
/// <summary>
11+
/// Gets or sets the type of the caching provider.
12+
/// </summary>
13+
/// <remarks>
14+
/// Reserved, do not used.
15+
/// </remarks>
16+
/// <value>The type of the caching provider.</value>
17+
public CachingProviderType CachingProviderType { get; set; }
18+
19+
/// <summary>
20+
/// Gets or sets the max random second.
21+
/// </summary>
22+
/// <remarks>
23+
/// Prevent Cache Crash
24+
/// </remarks>
25+
/// <value>The max random second.</value>
26+
public int MaxRdSecond { get; set; } = 120;
27+
28+
/// <summary>
29+
/// Gets or sets the order.
30+
/// </summary>
31+
/// <remarks>
32+
/// Mainly for hybird
33+
/// </remarks>
34+
/// <value>The order.</value>
35+
public int Order { get; set; }
36+
}
37+
38+
39+
}

src/EasyCaching.Core/Internal/HybridCachingKeyType.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/EasyCaching.HybridCache/EasyCaching.HybridCache.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<Owners>Catcher Wong</Owners>
66
<Authors>Catcher Wong</Authors>
7-
<Version>0.2.0</Version>
7+
<Version>0.2.1</Version>
88
<Description>
99
EasyCaching.HybridCache combines local caching and distributed caching.
1010
</Description>
@@ -15,7 +15,8 @@
1515
<ProjectUrl>https://github.com/dotnetcore/EasyCaching</ProjectUrl>
1616
<PackageIconUrl>https://raw.githubusercontent.com/dotnetcore/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
1717
<PackageReleaseNotes>
18-
Implement GetCount and Flush.
18+
1. Refactor;
19+
2. Simplify the configuration of Hybrid;
1920
</PackageReleaseNotes>
2021
</PropertyGroup>
2122

0 commit comments

Comments
 (0)