Skip to content

Commit

Permalink
Merge pull request #346 from dotnetcore/dev
Browse files Browse the repository at this point in the history
v1.5.1 release
  • Loading branch information
catcherwong authored Mar 9, 2022
2 parents 90d9768 + aa71851 commit fd4ca61
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 31 deletions.
19 changes: 9 additions & 10 deletions build/releasenotes.props
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<Project>
<PropertyGroup>
<EasyCachingCorePackageNotes>
1. Expose raw cache database.
1. Upgrading dependencies.
</EasyCachingCorePackageNotes>
<EasyCachingMemcachedPackageNotes>
1. Expose raw cache database.
1. Upgrading dependencies.
</EasyCachingMemcachedPackageNotes>
<EasyCachingRedisPackageNotes>
1. Expose raw cache database.
2. Support KeyPrefix.
1. Fix removebyprefix when enable keyprefix.
</EasyCachingRedisPackageNotes>
<EasyCachingSQLitePackageNotes>
1. Expose raw cache database.
1. Upgrading dependencies.
</EasyCachingSQLitePackageNotes>
<EasyCachingInMemoryPackageNotes>
1. Expose raw cache database.
1. Upgrading dependencies.
</EasyCachingInMemoryPackageNotes>
<EasyCachingHybridPackageNotes>
1. Upgrading dependencies.
Expand All @@ -38,7 +37,7 @@
1. Upgrading dependencies.
</EasyCachingProtobufPackageNotes>
<EasyCachingCSRedisPackageNotes>
1. Support distributed lock.
1. Upgrading dependencies.
</EasyCachingCSRedisPackageNotes>
<EasyCachingCSRedisBusPackageNotes>
1. Upgrading dependencies.
Expand All @@ -47,13 +46,13 @@
1. Upgrading dependencies.
</EasyCachingRedisBusPackageNotes>
<EasyCachingRabbitBusPackageNotes>
1. Upgrading dependencies.
</EasyCachingRabbitBusPackageNotes>
1. Allow user to define client provided name.
</EasyCachingRabbitBusPackageNotes>
<EasyCachingDiskPackageNotes>
1. Upgrading dependencies.
</EasyCachingDiskPackageNotes>
<EasyCachingLiteDBPackageNotes>
1. Expose raw cache database.
1. Upgrading dependencies.
</EasyCachingLiteDBPackageNotes>
<EasyCachingSTJsonPackageNotes>
1. Upgrading dependencies.
Expand Down
40 changes: 20 additions & 20 deletions build/version.props
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Project>
<PropertyGroup>
<EasyCachingCorePackageVersion>1.5.0</EasyCachingCorePackageVersion>
<EasyCachingMemcachedPackageVersion>1.5.0</EasyCachingMemcachedPackageVersion>
<EasyCachingRedisPackageVersion>1.5.0</EasyCachingRedisPackageVersion>
<EasyCachingSQLitePackageVersion>1.5.0</EasyCachingSQLitePackageVersion>
<EasyCachingInMemoryPackageVersion>1.5.0</EasyCachingInMemoryPackageVersion>
<EasyCachingHybridPackageVersion>1.5.0</EasyCachingHybridPackageVersion>
<EasyCachingAspectCorePackageVersion>1.5.0</EasyCachingAspectCorePackageVersion>
<EasyCachingCastlePackageVersion>1.5.0</EasyCachingCastlePackageVersion>
<EasyCachingResponseCachingPackageVersion>1.5.0</EasyCachingResponseCachingPackageVersion>
<EasyCachingJsonPackageVersion>1.5.0</EasyCachingJsonPackageVersion>
<EasyCachingMessagePackPackageVersion>1.5.0</EasyCachingMessagePackPackageVersion>
<EasyCachingProtobufPackageVersion>1.5.0</EasyCachingProtobufPackageVersion>
<EasyCachingCSRedisPackageVersion>1.5.0</EasyCachingCSRedisPackageVersion>
<EasyCachingRedisBusPackageVersion>1.5.0</EasyCachingRedisBusPackageVersion>
<EasyCachingCSRedisBusPackageVersion>1.5.0</EasyCachingCSRedisBusPackageVersion>
<EasyCachingRabbitBusPackageVersion>1.5.0</EasyCachingRabbitBusPackageVersion>
<EasyCachingDiskPackageVersion>1.5.0</EasyCachingDiskPackageVersion>
<EasyCachingMsExtPackageVersion>1.5.0</EasyCachingMsExtPackageVersion>
<EasyCachingLiteDBPackageVersion>1.5.0</EasyCachingLiteDBPackageVersion>
<EasyCachingSTJsonPackageVersion>1.5.0</EasyCachingSTJsonPackageVersion>
<EasyCachingCorePackageVersion>1.5.1</EasyCachingCorePackageVersion>
<EasyCachingMemcachedPackageVersion>1.5.1</EasyCachingMemcachedPackageVersion>
<EasyCachingRedisPackageVersion>1.5.1</EasyCachingRedisPackageVersion>
<EasyCachingSQLitePackageVersion>1.5.1</EasyCachingSQLitePackageVersion>
<EasyCachingInMemoryPackageVersion>1.5.1</EasyCachingInMemoryPackageVersion>
<EasyCachingHybridPackageVersion>1.5.1</EasyCachingHybridPackageVersion>
<EasyCachingAspectCorePackageVersion>1.5.1</EasyCachingAspectCorePackageVersion>
<EasyCachingCastlePackageVersion>1.5.1</EasyCachingCastlePackageVersion>
<EasyCachingResponseCachingPackageVersion>1.5.1</EasyCachingResponseCachingPackageVersion>
<EasyCachingJsonPackageVersion>1.5.1</EasyCachingJsonPackageVersion>
<EasyCachingMessagePackPackageVersion>1.5.1</EasyCachingMessagePackPackageVersion>
<EasyCachingProtobufPackageVersion>1.5.1</EasyCachingProtobufPackageVersion>
<EasyCachingCSRedisPackageVersion>1.5.1</EasyCachingCSRedisPackageVersion>
<EasyCachingRedisBusPackageVersion>1.5.1</EasyCachingRedisBusPackageVersion>
<EasyCachingCSRedisBusPackageVersion>1.5.1</EasyCachingCSRedisBusPackageVersion>
<EasyCachingRabbitBusPackageVersion>1.5.1</EasyCachingRabbitBusPackageVersion>
<EasyCachingDiskPackageVersion>1.5.1</EasyCachingDiskPackageVersion>
<EasyCachingMsExtPackageVersion>1.5.1</EasyCachingMsExtPackageVersion>
<EasyCachingLiteDBPackageVersion>1.5.1</EasyCachingLiteDBPackageVersion>
<EasyCachingSTJsonPackageVersion>1.5.1</EasyCachingSTJsonPackageVersion>
</PropertyGroup>
</Project>
3 changes: 2 additions & 1 deletion bus/EasyCaching.Bus.RabbitMQ/DefaultRabbitMQBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ IPooledObjectPolicy<IModel> _objectPolicy
VirtualHost = _options.VirtualHost,
RequestedConnectionTimeout = System.TimeSpan.FromMilliseconds(_options.RequestedConnectionTimeout),
SocketReadTimeout = System.TimeSpan.FromMilliseconds(_options.SocketReadTimeout),
SocketWriteTimeout = System.TimeSpan.FromMilliseconds(_options.SocketWriteTimeout)
SocketWriteTimeout = System.TimeSpan.FromMilliseconds(_options.SocketWriteTimeout),
ClientProvidedName = _options.ClientProvidedName
};

_subConnection = factory.CreateConnection();
Expand Down
6 changes: 6 additions & 0 deletions docs/Hybrid.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ public class Startup

services.AddEasyCaching(option =>
{
option.WithJson("myjson");

// local
option.UseInMemory("m1");
// distributed
option.UseRedis(config =>
{
config.DBConfig.Endpoints.Add(new Core.Configurations.ServerEndPoint("127.0.0.1", 6379));
config.DBConfig.Database = 5;
config.SerializerName = "myjson";
}, "myredis");

// combine local and distributed
Expand All @@ -58,6 +61,9 @@ public class Startup
.WithRedisBus(busConf =>
{
busConf.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6380));

// do not forget to set the SerializerName for the bus here !!
busConf.SerializerName = "myjson";
});
});
}
Expand Down
5 changes: 5 additions & 0 deletions src/EasyCaching.Core/Configurations/BaseRabbitMQOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,10 @@ public class BaseRabbitMQOptions
/// Gets or sets queue message automatic deletion time (in milliseconds). Default 864000000 ms (10 days).
/// </summary>
public int QueueMessageExpires { get; set; } = 864000000;

/// <summary>
/// Gets or sets the client-provided name for the rabbit connection. Default null (handled by rabbit client)
/// </summary>
public string ClientProvidedName { get; set; }
}
}
8 changes: 8 additions & 0 deletions src/EasyCaching.Redis/DefaultRedisCachingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ private RedisKey[] SearchRedisKeys(string pattern)
// from this redis dev specification, https://yq.aliyun.com/articles/531067 , maybe the appropriate scope is 100~500, using 200 here.
keys.AddRange(server.Keys(pattern: pattern, database: _cache.Database, pageSize: 200));

if (!string.IsNullOrWhiteSpace(_options.DBConfig.KeyPrefix))
keys = keys.Select(x => new RedisKey(
x.ToString().Remove(0, _options.DBConfig.KeyPrefix.Length)))
.ToList();

return keys.Distinct().ToArray();

//var keys = new HashSet<RedisKey>();
Expand Down Expand Up @@ -343,6 +348,9 @@ private string HandlePrefix(string prefix)
if (!prefix.EndsWith("*", StringComparison.OrdinalIgnoreCase))
prefix = string.Concat(prefix, "*");

if (!string.IsNullOrWhiteSpace(_options.DBConfig.KeyPrefix))
prefix = _options.DBConfig.KeyPrefix + prefix;

return prefix;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,5 +272,28 @@ public void KeyPrefixTest()
var val3 = WithKeyPrefix.Get<string>("KeyPrefix");
Assert.Equal(val1.Value, val3.Value);
}

[Fact]
public void RemoveByPrefixTest()
{
var WithKeyPrefix = _providerFactory.GetCachingProvider("WithKeyPrefix");

WithKeyPrefix.Set("KeyPrefix1", "ok", TimeSpan.FromSeconds(10));
WithKeyPrefix.Set("KeyPrefix2", "ok", TimeSpan.FromSeconds(10));

var val1 = WithKeyPrefix.Get<string>("KeyPrefix1");
var val2 = WithKeyPrefix.Get<string>("KeyPrefix2");

Assert.True(val1.HasValue);
Assert.True(val2.HasValue);
Assert.Equal(val1.Value, val2.Value);

WithKeyPrefix.RemoveByPrefix("Key");

var val3 = WithKeyPrefix.Get<string>("KeyPrefix1");
var val4 = WithKeyPrefix.Get<string>("KeyPrefix2");
Assert.False(val3.HasValue);
Assert.False(val4.HasValue);
}
}
}

0 comments on commit fd4ca61

Please sign in to comment.