Galosys.Foundation.RulesEngine.Redis
26.10.29.1
dotnet add package Galosys.Foundation.RulesEngine.Redis --version 26.10.29.1
NuGet\Install-Package Galosys.Foundation.RulesEngine.Redis -Version 26.10.29.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Galosys.Foundation.RulesEngine.Redis" Version="26.10.29.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Galosys.Foundation.RulesEngine.Redis" Version="26.10.29.1" />
<PackageReference Include="Galosys.Foundation.RulesEngine.Redis" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Galosys.Foundation.RulesEngine.Redis --version 26.10.29.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Galosys.Foundation.RulesEngine.Redis, 26.10.29.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Galosys.Foundation.RulesEngine.Redis@26.10.29.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Galosys.Foundation.RulesEngine.Redis&version=26.10.29.1
#tool nuget:?package=Galosys.Foundation.RulesEngine.Redis&version=26.10.29.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Galosys.Foundation.RulesEngine.Redis
规则引擎 Redis Pub/Sub 热更新广播模块,支持多实例部署时规则变更的跨实例同步通知。
依赖:
Galosys.Foundation.RulesEngine(必选)+Galosys.Foundation.Redis(必选)
快速开始
1. 注册服务
// Program.cs
services.AddRuleEngine(configuration);
services.AddRedisRuleChangeNotifier(configuration);
需先注册 Redis 实现(FreeRedis 或 StackExchange.Redis):
services.AddFreeRedis(configuration); // 或 services.AddStackExchangeRedis(configuration);
services.AddRuleEngine(configuration);
services.AddRedisRuleChangeNotifier(configuration);
2. 配置
{
"Rules": {
"Redis": {
"Channel": "rules:change"
}
}
}
| 配置项 | 默认值 | 说明 |
|---|---|---|
Rules:Redis:Channel |
"rules:change" |
Pub/Sub 频道名 |
3. 发布变更通知
管理后台修改规则后,通知所有实例刷新缓存:
public class RuleAdminController : ControllerBase
{
private readonly RuleChangePublisher _publisher;
public RuleAdminController(RuleChangePublisher publisher)
{
_publisher = publisher;
}
/// <summary>
/// 通知所有实例刷新指定规则集
/// </summary>
[HttpPost("rules/{ruleSet}/refresh")]
public async Task<IActionResult> RefreshRules(string ruleSet)
{
await _publisher.PublishAsync(ruleSet);
return Ok();
}
}
工作原理
实例 A (修改规则) ──publish──▶ Redis (rules:change channel)
│
┌───────────┼───────────┐
▼ ▼ ▼
实例 A 实例 B 实例 C
(清缓存) (清缓存) (清缓存)
RedisRuleChangeListener监听 Redis Pub/Sub 消息- 收到消息后调用
RuleSetCache.Remove(精准刷新)或Clear()(全量刷新) RuleChangePublisher发布变更通知,供管理后台调用
消息格式
{
"RuleSet": "discount",
"Type": "Updated"
}
| 字段 | 说明 |
|---|---|
RuleSet |
规则集名称(为空则全量刷新) |
Type |
变更类型:Added/Updated/Removed/Reloaded |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Galosys.Foundation.Redis (>= 26.10.29.1)
- Galosys.Foundation.RulesEngine (>= 26.10.29.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 26.10.29.1 | 110 | 10/29/2026 |
| 26.10.20.1 | 103 | 10/20/2026 |
| 26.10.16.2 | 100 | 10/16/2026 |
| 26.10.16.1 | 92 | 10/16/2026 |
| 26.10.9.1 | 98 | 10/9/2026 |
| 26.10.8.1 | 101 | 10/8/2026 |
| 26.9.23.1 | 118 | 9/23/2026 |
| 26.9.16.1 | 125 | 9/16/2026 |
| 26.9.15.1 | 101 | 9/15/2026 |
| 26.9.14.1 | 115 | 9/15/2026 |
| 26.8.29.1 | 117 | 8/31/2026 |
| 26.8.26.1 | 129 | 8/26/2026 |
| 26.8.23.1 | 127 | 8/23/2026 |
| 26.8.21.1 | 122 | 8/21/2026 |
| 26.8.20.1 | 120 | 8/20/2026 |
| 26.8.18.1 | 125 | 8/18/2026 |
| 26.8.17.1 | 132 | 8/17/2026 |
| 26.8.13.2 | 132 | 8/13/2026 |
| 26.8.13.1 | 123 | 8/13/2026 |
| 26.8.12.2 | 119 | 8/12/2026 |
Loading failed