Skip to content

Commit

Permalink
Merge pull request #36 from dotnetcore/dev
Browse files Browse the repository at this point in the history
Refactoring And Add new API
  • Loading branch information
catcherwong authored Apr 17, 2018
2 parents c928aae + f0d5d9b commit 94771e4
Show file tree
Hide file tree
Showing 35 changed files with 914 additions and 705 deletions.
30 changes: 8 additions & 22 deletions sample/EasyCaching.Demo.Providers/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,21 @@ public void ConfigureServices(IServiceCollection services)

////5. Important step for using Hybrid Cache
////5.1. Local Cache
//services.AddDefaultInMemoryCacheForHybrid();
//services.AddDefaultInMemoryCache(x=>
//{
// x.Order = 1;
//});
////5.2 Distributed Cache
//services.AddDefaultRedisCacheForHybrid(option =>
//services.AddDefaultRedisCache(option =>
//{
// option.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379));
// option.Password = "";
//}, x=>
//{
// x.Order = 2;//this value should greater than local caching provider
//});
////5.3 Hybrid
//services.AddDefaultHybridCache();
////5.4 Singleton
//services.AddSingleton(factory =>
//{
// Func<string, IEasyCachingProvider> accesor = key =>
// {
// if (key.Equals(HybridCachingKeyType.LocalKey))
// {
// return factory.GetService<DefaultInMemoryCachingProvider>();
// }
// else if (key.Equals(HybridCachingKeyType.DistributedKey))
// {
// return factory.GetService<DefaultRedisCachingProvider>();
// }
// else
// {
// throw new Exception();
// }
// };
// return accesor;
//});
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
Expand Down
15 changes: 15 additions & 0 deletions src/EasyCaching.Core/CachingProviderType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace EasyCaching.Core
{
/// <summary>
/// Caching provider type.
/// </summary>
public enum CachingProviderType
{
InMemory,
Memcached,
Redis,
SQLite,
Ext1,
Ext2
}
}
5 changes: 3 additions & 2 deletions src/EasyCaching.Core/EasyCaching.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Owners>Catcher Wong</Owners>
<Authors>Catcher Wong</Authors>
<Version>0.2.0</Version>
<Version>0.2.1</Version>
<Description>
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!
</Description>
Expand All @@ -15,7 +15,8 @@
<ProjectUrl>https://github.com/dotnetcore/EasyCaching</ProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/dotnetcore/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
<PackageReleaseNotes>
Add GetCount and Flush for providers.
1. Add FlushAsync for providers.
2. Add BaseProviderOptions.
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
28 changes: 0 additions & 28 deletions src/EasyCaching.Core/EasyCachingType.cs

This file was deleted.

18 changes: 18 additions & 0 deletions src/EasyCaching.Core/IEasyCachingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,23 @@ public interface IEasyCachingProvider
/// </summary>
/// <returns>The async.</returns>
Task FlushAsync();

/// <summary>
/// Gets the order.
/// </summary>
/// <value>The order.</value>
int Order { get; }

/// <summary>
/// Gets the max rd second.
/// </summary>
/// <value>The max random second.</value>
int MaxRdSecond { get; }

/// <summary>
/// Gets the type of the caching provider.
/// </summary>
/// <value>The type of the caching provider.</value>
CachingProviderType CachingProviderType { get; }
}
}
39 changes: 39 additions & 0 deletions src/EasyCaching.Core/Internal/BaseProviderOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace EasyCaching.Core.Internal
{
using System;

/// <summary>
/// Base provider options.
/// </summary>
public class BaseProviderOptions
{
/// <summary>
/// Gets or sets the type of the caching provider.
/// </summary>
/// <remarks>
/// Reserved, do not used.
/// </remarks>
/// <value>The type of the caching provider.</value>
public CachingProviderType CachingProviderType { get; set; }

/// <summary>
/// Gets or sets the max random second.
/// </summary>
/// <remarks>
/// Prevent Cache Crash
/// </remarks>
/// <value>The max random second.</value>
public int MaxRdSecond { get; set; } = 120;

/// <summary>
/// Gets or sets the order.
/// </summary>
/// <remarks>
/// Mainly for hybird
/// </remarks>
/// <value>The order.</value>
public int Order { get; set; }
}


}
18 changes: 0 additions & 18 deletions src/EasyCaching.Core/Internal/HybridCachingKeyType.cs

This file was deleted.

5 changes: 3 additions & 2 deletions src/EasyCaching.HybridCache/EasyCaching.HybridCache.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Owners>Catcher Wong</Owners>
<Authors>Catcher Wong</Authors>
<Version>0.2.0</Version>
<Version>0.2.1</Version>
<Description>
EasyCaching.HybridCache combines local caching and distributed caching.
</Description>
Expand All @@ -15,7 +15,8 @@
<ProjectUrl>https://github.com/dotnetcore/EasyCaching</ProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/dotnetcore/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
<PackageReleaseNotes>
Implement GetCount and Flush.
1. Refactor;
2. Simplify the configuration of Hybrid;
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
Loading

0 comments on commit 94771e4

Please sign in to comment.