Skip to content

Commit

Permalink
Merge pull request #27 from dotnetcore/dev
Browse files Browse the repository at this point in the history
Release new version
  • Loading branch information
catcherwong authored Mar 24, 2018
2 parents 295092d + fd59689 commit ed49429
Show file tree
Hide file tree
Showing 24 changed files with 335 additions and 135 deletions.
16 changes: 8 additions & 8 deletions src/EasyCaching.Core/EasyCaching.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Owners>Catcher Wong</Owners>
<Authors>Catcher Wong</Authors>
<Version>0.1.4</Version>
<Version>0.2.0</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>
<PackageTags>Caching,Cache,Distributed,Memory,Interceptor,Synchronization,Hybrid</PackageTags>
<PackageProjectUrl>https://github.com/catcherwong/EasyCaching</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/catcherwong/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/catcherwong/EasyCaching</RepositoryUrl>
<ProjectUrl>https://github.com/catcherwong/EasyCaching</ProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/catcherwong/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
<PackageReleaseNotes>
Add some new caching APIs.
<PackageProjectUrl>https://github.com/dotnetcore/EasyCaching</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/dotnetcore/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/dotnetcore/EasyCaching</RepositoryUrl>
<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.
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
12 changes: 12 additions & 0 deletions src/EasyCaching.Core/IEasyCachingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,17 @@ public interface IEasyCachingProvider
/// <returns>The all async.</returns>
/// <param name="cacheKeys">Cache keys.</param>
Task RemoveAllAsync(IEnumerable<string> cacheKeys);

/// <summary>
/// Gets the count.
/// </summary>
/// <returns>The count.</returns>
/// <param name="prefix">Prefix.</param>
int GetCount(string prefix = "");

/// <summary>
/// Flush this instance.
/// </summary>
void Flush();
}
}
7 changes: 7 additions & 0 deletions src/EasyCaching.Core/Internal/BaseRedisOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,12 @@ public class BaseRedisOptions
/// The endpoints.
/// </value>
public IList<ServerEndPoint> Endpoints { get; } = new List<ServerEndPoint>();

/// <summary>
/// Gets or sets a value indicating whether this <see cref="T:EasyCaching.Core.Internal.BaseRedisOptions"/>
/// allow admin.
/// </summary>
/// <value><c>true</c> if allow admin; otherwise, <c>false</c>.</value>
public bool AllowAdmin { get; set; } = false;
}
}
14 changes: 7 additions & 7 deletions src/EasyCaching.HybridCache/EasyCaching.HybridCache.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Owners>Catcher Wong</Owners>
<Authors>Catcher Wong</Authors>
<Version>0.1.2</Version>
<Version>0.2.0</Version>
<Description>
EasyCaching.HybridCache combines local caching and distributed caching.
</Description>
<PackageTags>Caching,Cache,Synchronization,Hybrid</PackageTags>
<PackageProjectUrl>https://github.com/catcherwong/EasyCaching</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/catcherwong/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/catcherwong/EasyCaching</RepositoryUrl>
<ProjectUrl>https://github.com/catcherwong/EasyCaching</ProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/catcherwong/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/dotnetcore/EasyCaching</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/dotnetcore/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/dotnetcore/EasyCaching</RepositoryUrl>
<ProjectUrl>https://github.com/dotnetcore/EasyCaching</ProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/dotnetcore/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
<PackageReleaseNotes>
Add some new caching APIs.
Implement GetCount and Flush.
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
27 changes: 27 additions & 0 deletions src/EasyCaching.HybridCache/HybridCachingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,32 @@ public async Task RemoveAllAsync(IEnumerable<string> cacheKeys)
System.Console.WriteLine(ex.Message);
}
}

/// <summary>
/// Gets the count.
/// </summary>
/// <returns>The count.</returns>
/// <param name="prefix">Prefix.</param>
public int GetCount(string prefix = "")
{
return Math.Max(_localCachingProvider.GetCount(prefix), _distributedCachingProvider.GetCount(prefix));
}

/// <summary>
/// Flush this instance.
/// </summary>
public void Flush()
{
_localCachingProvider.Flush();

try
{
_distributedCachingProvider.Flush();
}
catch (Exception ex)
{
System.Console.WriteLine(ex.Message);
}
}
}
}
26 changes: 26 additions & 0 deletions src/EasyCaching.InMemory/DefaultInMemoryCachingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -455,5 +455,31 @@ public async Task RemoveAllAsync(IEnumerable<string> cacheKeys)

await Task.WhenAll(tasks);
}

/// <summary>
/// Gets the count.
/// </summary>
/// <returns>The count.</returns>
/// <param name="prefix">Prefix.</param>
public int GetCount(string prefix = "")
{
return string.IsNullOrWhiteSpace(prefix)
? _cacheKeys.Count
: _cacheKeys.Count(x => x.StartsWith(prefix.Trim(), StringComparison.OrdinalIgnoreCase));
}

/// <summary>
/// Flush this instance.
/// </summary>
public void Flush()
{
////new instance
//_cache = new MemoryCache(new MemoryCacheOptions());

foreach (var item in _cacheKeys)
_cache.Remove(item);

_cacheKeys.Clear();
}
}
}
14 changes: 7 additions & 7 deletions src/EasyCaching.InMemory/EasyCaching.InMemory.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Owners>Catcher Wong</Owners>
<Authors>Catcher Wong</Authors>
<Version>0.1.4</Version>
<Version>0.2.0</Version>
<Description>
In-memory cache based on EasyCaching.Core and Microsoft.Extensions.Caching.Memory
</Description>
<PackageTags>Caching,Cache,In-Memory</PackageTags>
<PackageProjectUrl>https://github.com/catcherwong/EasyCaching</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/catcherwong/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/catcherwong/EasyCaching</RepositoryUrl>
<ProjectUrl>https://github.com/catcherwong/EasyCaching</ProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/catcherwong/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/dotnetcore/EasyCaching</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/dotnetcore/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/dotnetcore/EasyCaching</RepositoryUrl>
<ProjectUrl>https://github.com/dotnetcore/EasyCaching</ProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/dotnetcore/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
<PackageReleaseNotes>
Add some new caching APIs.
Implement GetCount and Flush.
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,18 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Owners>Catcher Wong</Owners>
<Authors>Catcher Wong</Authors>
<Version>0.1.2</Version>
<Version>0.2.0</Version>
<Description>
Caching Interceptor based on EasyCaching.Core and AspectCore
</Description>
<PackageTags>Caching,Cache,Distributed,Memory,Interceptor,Synchronization</PackageTags>
<PackageProjectUrl>https://github.com/catcherwong/EasyCaching</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/catcherwong/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/catcherwong/EasyCaching</RepositoryUrl>
<ProjectUrl>https://github.com/catcherwong/EasyCaching</ProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/catcherwong/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/dotnetcore/EasyCaching</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/dotnetcore/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/dotnetcore/EasyCaching</RepositoryUrl>
<ProjectUrl>https://github.com/dotnetcore/EasyCaching</ProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/dotnetcore/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
<PackageReleaseNotes>
v0.1.2
1. Enable IsAll when using Evict.

v0.1.1
1. Get caching with data retriever =&gt; without data retriever .
2. Caching Handle with async method.
3. Introduct Able , Put And Evict.

v0.1.0
Init.
Add some extension methods.
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,18 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Owners>Catcher Wong</Owners>
<Authors>Catcher Wong</Authors>
<Version>0.1.2</Version>
<Version>0.2.0</Version>
<Description>
Caching Interceptor based on EasyCaching.Core and Castle
</Description>
<PackageTags>Caching,Cache,Distributed,Memory,Interceptor,Synchronization</PackageTags>
<PackageProjectUrl>https://github.com/catcherwong/EasyCaching</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/catcherwong/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/catcherwong/EasyCaching</RepositoryUrl>
<ProjectUrl>https://github.com/catcherwong/EasyCaching</ProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/catcherwong/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/dotnetcore/EasyCaching</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/dotnetcore/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/dotnetcore/EasyCaching</RepositoryUrl>
<ProjectUrl>https://github.com/dotnetcore/EasyCaching</ProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/dotnetcore/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
<PackageReleaseNotes>
v0.1.2
1. Enable IsAll when using Evict.

v0.1.1
1. Get caching with data retriever =&gt; without data retriever .
2. Introduct Able , Put And Evict.

v 0.1.0
Init.
Add some extension methods.
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
27 changes: 27 additions & 0 deletions src/EasyCaching.Memcached/DefaultMemcachedCachingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -460,5 +460,32 @@ public async Task RemoveAllAsync(IEnumerable<string> cacheKeys)

await Task.WhenAll(tasks);
}

/// <summary>
/// Gets the count.
/// </summary>
/// <returns>The count.</returns>
/// <param name="prefix">Prefix.</param>
public int GetCount(string prefix = "")
{
if(string.IsNullOrWhiteSpace(prefix))
{
//Inaccurate, sometimes, memcached just causes items to expire but not free up or flush memory at once.
return int.Parse(_memcachedClient.Stats().GetRaw("curr_items").FirstOrDefault().Value);
}
else
{
return 0;
}
}

/// <summary>
/// Flush this instance.
/// </summary>
public void Flush()
{
//not flush memory at once, just causes all items to expire
_memcachedClient.FlushAll();
}
}
}
14 changes: 7 additions & 7 deletions src/EasyCaching.Memcached/EasyCaching.Memcached.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Owners>Catcher Wong</Owners>
<Authors>Catcher Wong</Authors>
<Version>0.1.5</Version>
<Version>0.2.0</Version>
<Description>
EasyCaching.Memcached based on EasyCaching.Core and EnyimMemcachedCore
</Description>
<PackageTags>Caching,Cache,Distributed,Memcached</PackageTags>
<PackageProjectUrl>https://github.com/catcherwong/EasyCaching</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/catcherwong/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/catcherwong/EasyCaching</RepositoryUrl>
<ProjectUrl>https://github.com/catcherwong/EasyCaching</ProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/catcherwong/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/dotnetcore/EasyCaching</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/dotnetcore/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/dotnetcore/EasyCaching</RepositoryUrl>
<ProjectUrl>https://github.com/dotnetcore/EasyCaching</ProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/dotnetcore/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
<PackageReleaseNotes>
Simplify the usage of Memcached Transcoder
Implement GetCount and Flush.
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
31 changes: 31 additions & 0 deletions src/EasyCaching.Redis/DefaultRedisCachingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,5 +553,36 @@ public async Task RemoveAllAsync(IEnumerable<string> cacheKeys)
if (redisKeys.Length > 0)
await _cache.KeyDeleteAsync(redisKeys);
}

/// <summary>
/// Gets the count.
/// </summary>
/// <returns>The count.</returns>
/// <param name="prefix">Prefix.</param>
public int GetCount(string prefix = "")
{
if(string.IsNullOrWhiteSpace(prefix))
{
var allCount = 0;

foreach (var server in _servers)
allCount += (int)server.DatabaseSize(_cache.Database);

return allCount;
}

return this.SearchRedisKeys(this.HandlePrefix(prefix)).Length;
}

/// <summary>
/// Flush this instance.
/// </summary>
public void Flush()
{
foreach (var server in _servers)
{
server.FlushDatabase(_cache.Database);
}
}
}
}
14 changes: 7 additions & 7 deletions src/EasyCaching.Redis/EasyCaching.Redis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Owners>Catcher Wong</Owners>
<Authors>Catcher Wong</Authors>
<Version>0.1.4</Version>
<Version>0.2.0</Version>
<Description>
EasyCaching.Redis based on EasyCaching.Core and StackExchange.Redis
</Description>
<PackageTags>Caching,Cache,Distributed,Redis</PackageTags>
<PackageProjectUrl>https://github.com/catcherwong/EasyCaching</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/catcherwong/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/catcherwong/EasyCaching</RepositoryUrl>
<ProjectUrl>https://github.com/catcherwong/EasyCaching</ProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/catcherwong/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/dotnetcore/EasyCaching</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/dotnetcore/EasyCaching/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/dotnetcore/EasyCaching</RepositoryUrl>
<ProjectUrl>https://github.com/dotnetcore/EasyCaching</ProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/dotnetcore/EasyCaching/master/media/nuget-icon.png</PackageIconUrl>
<PackageReleaseNotes>
Add some new caching APIs.
Implement GetCount and Flush.
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions src/EasyCaching.Redis/RedisDatabaseProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private ConnectionMultiplexer CreateConnectionMultiplexer()
Password = _options.Password,
Ssl = _options.IsSsl,
SslHost = _options.SslHost,
AllowAdmin = _options.AllowAdmin
};

foreach (var endpoint in _options.Endpoints)
Expand Down
19 changes: 19 additions & 0 deletions src/EasyCaching.SQLite/ConstSQL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,25 @@ FROM [easycaching]
FROM [easycaching]
WHERE [cachekey] = @cachekey AND [expiration] > strftime('%s','now')";

/// <summary>
/// The countallsql.
/// </summary>
public const string COUNTALLSQL = @"SELECT COUNT(1)
FROM [easycaching]
WHERE [expiration] > strftime('%s','now')";

/// <summary>
/// The countprefixsql.
/// </summary>
public const string COUNTPREFIXSQL = @"SELECT COUNT(1)
FROM [easycaching]
WHERE [cachekey] like @cachekey AND [expiration] > strftime('%s','now')";

/// <summary>
/// The flushsql.
/// </summary>
public const string FLUSHSQL = @"DELETE FROM [easycaching]";

/// <summary>
/// The createsql.
/// </summary>
Expand Down
Loading

0 comments on commit ed49429

Please sign in to comment.