Skip to content

Commit ed49429

Browse files
authored
Merge pull request #27 from dotnetcore/dev
Release new version
2 parents 295092d + fd59689 commit ed49429

24 files changed

+335
-135
lines changed

src/EasyCaching.Core/EasyCaching.Core.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<Owners>Catcher Wong</Owners>
66
<Authors>Catcher Wong</Authors>
7-
<Version>0.1.4</Version>
7+
<Version>0.2.0</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>
1111
<PackageTags>Caching,Cache,Distributed,Memory,Interceptor,Synchronization,Hybrid</PackageTags>
12-
<PackageProjectUrl>https://github.com/catcherwong/EasyCaching</PackageProjectUrl>
13-
<PackageLicenseUrl>https://github.com/catcherwong/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
14-
<RepositoryUrl>https://github.com/catcherwong/EasyCaching</RepositoryUrl>
15-
<ProjectUrl>https://github.com/catcherwong/EasyCaching</ProjectUrl>
16-
<PackageIconUrl>https://raw.githubusercontent.com/catcherwong/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
17-
<PackageReleaseNotes>
18-
Add some new caching APIs.
12+
<PackageProjectUrl>https://github.com/dotnetcore/EasyCaching</PackageProjectUrl>
13+
<PackageLicenseUrl>https://github.com/dotnetcore/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
14+
<RepositoryUrl>https://github.com/dotnetcore/EasyCaching</RepositoryUrl>
15+
<ProjectUrl>https://github.com/dotnetcore/EasyCaching</ProjectUrl>
16+
<PackageIconUrl>https://raw.githubusercontent.com/dotnetcore/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
17+
<PackageReleaseNotes>
18+
Add GetCount and Flush for providers.
1919
</PackageReleaseNotes>
2020
</PropertyGroup>
2121

src/EasyCaching.Core/IEasyCachingProvider.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,17 @@ public interface IEasyCachingProvider
189189
/// <returns>The all async.</returns>
190190
/// <param name="cacheKeys">Cache keys.</param>
191191
Task RemoveAllAsync(IEnumerable<string> cacheKeys);
192+
193+
/// <summary>
194+
/// Gets the count.
195+
/// </summary>
196+
/// <returns>The count.</returns>
197+
/// <param name="prefix">Prefix.</param>
198+
int GetCount(string prefix = "");
199+
200+
/// <summary>
201+
/// Flush this instance.
202+
/// </summary>
203+
void Flush();
192204
}
193205
}

src/EasyCaching.Core/Internal/BaseRedisOptions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,12 @@ public class BaseRedisOptions
4747
/// The endpoints.
4848
/// </value>
4949
public IList<ServerEndPoint> Endpoints { get; } = new List<ServerEndPoint>();
50+
51+
/// <summary>
52+
/// Gets or sets a value indicating whether this <see cref="T:EasyCaching.Core.Internal.BaseRedisOptions"/>
53+
/// allow admin.
54+
/// </summary>
55+
/// <value><c>true</c> if allow admin; otherwise, <c>false</c>.</value>
56+
public bool AllowAdmin { get; set; } = false;
5057
}
5158
}

src/EasyCaching.HybridCache/EasyCaching.HybridCache.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<Owners>Catcher Wong</Owners>
66
<Authors>Catcher Wong</Authors>
7-
<Version>0.1.2</Version>
7+
<Version>0.2.0</Version>
88
<Description>
99
EasyCaching.HybridCache combines local caching and distributed caching.
1010
</Description>
1111
<PackageTags>Caching,Cache,Synchronization,Hybrid</PackageTags>
12-
<PackageProjectUrl>https://github.com/catcherwong/EasyCaching</PackageProjectUrl>
13-
<PackageLicenseUrl>https://github.com/catcherwong/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
14-
<RepositoryUrl>https://github.com/catcherwong/EasyCaching</RepositoryUrl>
15-
<ProjectUrl>https://github.com/catcherwong/EasyCaching</ProjectUrl>
16-
<PackageIconUrl>https://raw.githubusercontent.com/catcherwong/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
12+
<PackageProjectUrl>https://github.com/dotnetcore/EasyCaching</PackageProjectUrl>
13+
<PackageLicenseUrl>https://github.com/dotnetcore/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
14+
<RepositoryUrl>https://github.com/dotnetcore/EasyCaching</RepositoryUrl>
15+
<ProjectUrl>https://github.com/dotnetcore/EasyCaching</ProjectUrl>
16+
<PackageIconUrl>https://raw.githubusercontent.com/dotnetcore/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
1717
<PackageReleaseNotes>
18-
Add some new caching APIs.
18+
Implement GetCount and Flush.
1919
</PackageReleaseNotes>
2020
</PropertyGroup>
2121

src/EasyCaching.HybridCache/HybridCachingProvider.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,5 +585,32 @@ public async Task RemoveAllAsync(IEnumerable<string> cacheKeys)
585585
System.Console.WriteLine(ex.Message);
586586
}
587587
}
588+
589+
/// <summary>
590+
/// Gets the count.
591+
/// </summary>
592+
/// <returns>The count.</returns>
593+
/// <param name="prefix">Prefix.</param>
594+
public int GetCount(string prefix = "")
595+
{
596+
return Math.Max(_localCachingProvider.GetCount(prefix), _distributedCachingProvider.GetCount(prefix));
597+
}
598+
599+
/// <summary>
600+
/// Flush this instance.
601+
/// </summary>
602+
public void Flush()
603+
{
604+
_localCachingProvider.Flush();
605+
606+
try
607+
{
608+
_distributedCachingProvider.Flush();
609+
}
610+
catch (Exception ex)
611+
{
612+
System.Console.WriteLine(ex.Message);
613+
}
614+
}
588615
}
589616
}

src/EasyCaching.InMemory/DefaultInMemoryCachingProvider.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,5 +455,31 @@ public async Task RemoveAllAsync(IEnumerable<string> cacheKeys)
455455

456456
await Task.WhenAll(tasks);
457457
}
458+
459+
/// <summary>
460+
/// Gets the count.
461+
/// </summary>
462+
/// <returns>The count.</returns>
463+
/// <param name="prefix">Prefix.</param>
464+
public int GetCount(string prefix = "")
465+
{
466+
return string.IsNullOrWhiteSpace(prefix)
467+
? _cacheKeys.Count
468+
: _cacheKeys.Count(x => x.StartsWith(prefix.Trim(), StringComparison.OrdinalIgnoreCase));
469+
}
470+
471+
/// <summary>
472+
/// Flush this instance.
473+
/// </summary>
474+
public void Flush()
475+
{
476+
////new instance
477+
//_cache = new MemoryCache(new MemoryCacheOptions());
478+
479+
foreach (var item in _cacheKeys)
480+
_cache.Remove(item);
481+
482+
_cacheKeys.Clear();
483+
}
458484
}
459485
}

src/EasyCaching.InMemory/EasyCaching.InMemory.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<Owners>Catcher Wong</Owners>
66
<Authors>Catcher Wong</Authors>
7-
<Version>0.1.4</Version>
7+
<Version>0.2.0</Version>
88
<Description>
99
In-memory cache based on EasyCaching.Core and Microsoft.Extensions.Caching.Memory
1010
</Description>
1111
<PackageTags>Caching,Cache,In-Memory</PackageTags>
12-
<PackageProjectUrl>https://github.com/catcherwong/EasyCaching</PackageProjectUrl>
13-
<PackageLicenseUrl>https://github.com/catcherwong/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
14-
<RepositoryUrl>https://github.com/catcherwong/EasyCaching</RepositoryUrl>
15-
<ProjectUrl>https://github.com/catcherwong/EasyCaching</ProjectUrl>
16-
<PackageIconUrl>https://raw.githubusercontent.com/catcherwong/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
12+
<PackageProjectUrl>https://github.com/dotnetcore/EasyCaching</PackageProjectUrl>
13+
<PackageLicenseUrl>https://github.com/dotnetcore/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
14+
<RepositoryUrl>https://github.com/dotnetcore/EasyCaching</RepositoryUrl>
15+
<ProjectUrl>https://github.com/dotnetcore/EasyCaching</ProjectUrl>
16+
<PackageIconUrl>https://raw.githubusercontent.com/dotnetcore/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
1717
<PackageReleaseNotes>
18-
Add some new caching APIs.
18+
Implement GetCount and Flush.
1919
</PackageReleaseNotes>
2020
</PropertyGroup>
2121

src/EasyCaching.Interceptor.AspectCore/EasyCaching.Interceptor.AspectCore.csproj

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,18 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<Owners>Catcher Wong</Owners>
66
<Authors>Catcher Wong</Authors>
7-
<Version>0.1.2</Version>
7+
<Version>0.2.0</Version>
88
<Description>
99
Caching Interceptor based on EasyCaching.Core and AspectCore
1010
</Description>
1111
<PackageTags>Caching,Cache,Distributed,Memory,Interceptor,Synchronization</PackageTags>
12-
<PackageProjectUrl>https://github.com/catcherwong/EasyCaching</PackageProjectUrl>
13-
<PackageLicenseUrl>https://github.com/catcherwong/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
14-
<RepositoryUrl>https://github.com/catcherwong/EasyCaching</RepositoryUrl>
15-
<ProjectUrl>https://github.com/catcherwong/EasyCaching</ProjectUrl>
16-
<PackageIconUrl>https://raw.githubusercontent.com/catcherwong/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
12+
<PackageProjectUrl>https://github.com/dotnetcore/EasyCaching</PackageProjectUrl>
13+
<PackageLicenseUrl>https://github.com/dotnetcore/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
14+
<RepositoryUrl>https://github.com/dotnetcore/EasyCaching</RepositoryUrl>
15+
<ProjectUrl>https://github.com/dotnetcore/EasyCaching</ProjectUrl>
16+
<PackageIconUrl>https://raw.githubusercontent.com/dotnetcore/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
1717
<PackageReleaseNotes>
18-
v0.1.2
19-
1. Enable IsAll when using Evict.
20-
21-
v0.1.1
22-
1. Get caching with data retriever =&gt; without data retriever .
23-
2. Caching Handle with async method.
24-
3. Introduct Able , Put And Evict.
25-
26-
v0.1.0
27-
Init.
18+
Add some extension methods.
2819
</PackageReleaseNotes>
2920
</PropertyGroup>
3021

src/EasyCaching.Interceptor.Castle/EasyCaching.Interceptor.Castle.csproj

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,18 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<Owners>Catcher Wong</Owners>
66
<Authors>Catcher Wong</Authors>
7-
<Version>0.1.2</Version>
7+
<Version>0.2.0</Version>
88
<Description>
99
Caching Interceptor based on EasyCaching.Core and Castle
1010
</Description>
1111
<PackageTags>Caching,Cache,Distributed,Memory,Interceptor,Synchronization</PackageTags>
12-
<PackageProjectUrl>https://github.com/catcherwong/EasyCaching</PackageProjectUrl>
13-
<PackageLicenseUrl>https://github.com/catcherwong/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
14-
<RepositoryUrl>https://github.com/catcherwong/EasyCaching</RepositoryUrl>
15-
<ProjectUrl>https://github.com/catcherwong/EasyCaching</ProjectUrl>
16-
<PackageIconUrl>https://raw.githubusercontent.com/catcherwong/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
12+
<PackageProjectUrl>https://github.com/dotnetcore/EasyCaching</PackageProjectUrl>
13+
<PackageLicenseUrl>https://github.com/dotnetcore/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
14+
<RepositoryUrl>https://github.com/dotnetcore/EasyCaching</RepositoryUrl>
15+
<ProjectUrl>https://github.com/dotnetcore/EasyCaching</ProjectUrl>
16+
<PackageIconUrl>https://raw.githubusercontent.com/dotnetcore/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
1717
<PackageReleaseNotes>
18-
v0.1.2
19-
1. Enable IsAll when using Evict.
20-
21-
v0.1.1
22-
1. Get caching with data retriever =&gt; without data retriever .
23-
2. Introduct Able , Put And Evict.
24-
25-
v 0.1.0
26-
Init.
18+
Add some extension methods.
2719
</PackageReleaseNotes>
2820
</PropertyGroup>
2921

src/EasyCaching.Memcached/DefaultMemcachedCachingProvider.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,5 +460,32 @@ public async Task RemoveAllAsync(IEnumerable<string> cacheKeys)
460460

461461
await Task.WhenAll(tasks);
462462
}
463+
464+
/// <summary>
465+
/// Gets the count.
466+
/// </summary>
467+
/// <returns>The count.</returns>
468+
/// <param name="prefix">Prefix.</param>
469+
public int GetCount(string prefix = "")
470+
{
471+
if(string.IsNullOrWhiteSpace(prefix))
472+
{
473+
//Inaccurate, sometimes, memcached just causes items to expire but not free up or flush memory at once.
474+
return int.Parse(_memcachedClient.Stats().GetRaw("curr_items").FirstOrDefault().Value);
475+
}
476+
else
477+
{
478+
return 0;
479+
}
480+
}
481+
482+
/// <summary>
483+
/// Flush this instance.
484+
/// </summary>
485+
public void Flush()
486+
{
487+
//not flush memory at once, just causes all items to expire
488+
_memcachedClient.FlushAll();
489+
}
463490
}
464491
}

0 commit comments

Comments
 (0)