Skip to content

Commit ab0a27b

Browse files
authored
Merge pull request #327 from Senparc/Develop
CsRedis v2.3.0 update BaseRedisObjectCacheStrategy.Client init progress
2 parents 306656d + 9a59313 commit ab0a27b

File tree

5 files changed

+21
-23
lines changed

5 files changed

+21
-23
lines changed

Sample/Senparc.CO2NET.Sample.Consoles/Program.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ and limitations under the License.
9797
* 1、Redis 的连接字符串信息会从 Config.SenparcSetting.Cache_Redis_Configuration 自动获取并注册,如不需要修改,下方方法可以忽略
9898
/* 2、如需手动修改,可以通过下方 SetConfigurationOption 方法手动设置 Redis 链接信息(仅修改配置,不立即启用)
9999
*/
100-
Senparc.CO2NET.Cache.Redis.Register.SetConfigurationOption(redisConfigurationStr);
101-
Console.WriteLine("完成 Redis 设置");
100+
Senparc.CO2NET.Cache.CsRedis.Register.SetConfigurationOption(redisConfigurationStr);
101+
Console.WriteLine("完成 CsRedis 设置");
102102

103103

104104
//以下会立即将全局缓存设置为 Redis
105-
Senparc.CO2NET.Cache.Redis.Register.UseKeyValueRedisNow();//键值对缓存策略(推荐)
106-
Console.WriteLine("启用 Redis UseKeyValue 策略");
105+
Senparc.CO2NET.Cache.CsRedis.Register.UseKeyValueRedisNow();//键值对缓存策略(推荐)
106+
Console.WriteLine("启用 CsRedis UseKeyValue 策略");
107107

108108
//Senparc.CO2NET.Cache.Redis.Register.UseHashRedisNow();//HashSet储存格式的缓存策略
109109

src/Senparc.CO2NET.Cache.CsRedis.Tests/InitTests.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,8 @@ public void AutoRegisterConfigurationTest()
5151
.UseSenparcGlobal();
5252
Assert.AreEqual(null, RedisManager.ConfigurationOption);// Not registered yet
5353

54-
registerService.RegisterCacheRedis(
55-
redisServer,
56-
redisConfiguration => RedisObjectCacheStrategy.Instance// Will automatically register on the first call
57-
);
58-
Assert.AreEqual(redisServer, RedisManager.ConfigurationOption);
54+
Register.SetConfigurationOption(redisServer);
55+
\ Assert.AreEqual(redisServer, RedisManager.ConfigurationOption);
5956

6057
var currentCache = CacheStrategyFactory.GetObjectCacheStrategyInstance();
6158
Assert.IsInstanceOfType(currentCache, typeof(RedisObjectCacheStrategy));

src/Senparc.CO2NET.Cache.CsRedis/ObjectCacheStrategy/BaseRedisObjectCacheStrategy.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ protected BaseRedisObjectCacheStrategy()
5151

5252
static bool CanUseRedis()
5353
{
54-
return string.IsNullOrEmpty(RedisManager.ConfigurationOption) &&
55-
!string.IsNullOrEmpty(Config.SenparcSetting.Cache_Redis_Configuration) &&
54+
return !string.IsNullOrEmpty(RedisManager.ConfigurationOption) ||
55+
(!string.IsNullOrEmpty(Config.SenparcSetting.Cache_Redis_Configuration) &&
5656
Config.SenparcSetting.Cache_Redis_Configuration != "Redis配置" &&
57-
Config.SenparcSetting.Cache_Redis_Configuration != "#{Cache_Redis_Configuration}#";
57+
Config.SenparcSetting.Cache_Redis_Configuration != "#{Cache_Redis_Configuration}#");
5858
}
5959

6060
static BaseRedisObjectCacheStrategy()

src/Senparc.CO2NET.Cache.CsRedis/Register.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static class Register
3636
/// <param name="redisConfigurationString">Redis connection string</param>
3737
/// <param name="redisObjectCacheStrategyInstance">Cache strategy delegate, the first parameter is redisConfigurationString</param>
3838
/// <returns></returns>
39-
[Obsolete("The registration process has been automated. Please use the Register.SetConfigurationOption() method to modify the connection string.")]
39+
[Obsolete("The registration process has been automated. Please use the Register.SetConfigurationOption() method to modify the connection string.", true)]
4040
public static IRegisterService RegisterCacheRedis(this IRegisterService registerService,
4141
string redisConfigurationString,
4242
Func<string, IBaseObjectCacheStrategy> redisObjectCacheStrategyInstance)

src/Senparc.CO2NET.Cache.CsRedis/Senparc.CO2NET.Cache.CsRedis.csproj

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
4-
<Version>2.2.0.2</Version>
4+
<Version>2.3.0</Version>
55
<AssemblyName>Senparc.CO2NET.Cache.CsRedis</AssemblyName>
66
<RootNamespace>Senparc.CO2NET.Cache.CsRedis</RootNamespace>
77
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>
@@ -22,15 +22,16 @@
2222
<PackageProjectUrl>https://github.com/JeffreySu/WeiXinMPSDK</PackageProjectUrl>
2323
<PackageIcon>icon.jpg</PackageIcon>
2424
<PackageReleaseNotes>
25-
v0.1.0 Genesis
26-
v0.5.2 BaseRedisObjectCacheStrategy destructor performs null value check and adds "#{Cache_Redis_Configuration}#" filter check
27-
v1.1.4 RedisObjectCacheStrategy and RedisHashSetObjectCacheStrategy.Get() methods add pure string check
28-
v1.2.5 Fix bug where GetAllByPrefixAsync(key) method automatically retrieves all keys
29-
[2024-09-11] v1.2.6 Update Cache, remove InsertToCache(), add Count(prefix)
30-
[2024-10-24] v2.0.1-beta1 fix: GetCountAsync(string prefix) #306 Thanks to @rendyu
31-
[2024-11-28] v2.1.1-beta1 Add UseLowerCaseApiName property for SenparcSetting
32-
[2024-12-04] v2.2.0-beta1 update Start() method, set SenparcSetting in Config when AddSenparcGlobalService() run
33-
</PackageReleaseNotes>
25+
v0.1.0 Genesis
26+
v0.5.2 BaseRedisObjectCacheStrategy destructor performs null value check and adds "#{Cache_Redis_Configuration}#" filter check
27+
v1.1.4 RedisObjectCacheStrategy and RedisHashSetObjectCacheStrategy.Get() methods add pure string check
28+
v1.2.5 Fix bug where GetAllByPrefixAsync(key) method automatically retrieves all keys
29+
[2024-09-11] v1.2.6 Update Cache, remove InsertToCache(), add Count(prefix)
30+
[2024-10-24] v2.0.1-beta1 fix: GetCountAsync(string prefix) #306 Thanks to @rendyu
31+
[2024-11-28] v2.1.1-beta1 Add UseLowerCaseApiName property for SenparcSetting
32+
[2024-12-04] v2.2.0-beta1 update Start() method, set SenparcSetting in Config when AddSenparcGlobalService() run
33+
[2025-08-18] v2.3.0 update BaseRedisObjectCacheStrategy.Client init progress
34+
</PackageReleaseNotes>
3435
<RepositoryUrl>https://github.com/Senparc/Senparc.CO2NET</RepositoryUrl>
3536
<Configurations>Debug;Release;Test</Configurations>
3637
</PropertyGroup>

0 commit comments

Comments
 (0)