![]() |
VOOZH | about |
dotnet add package Galosys.Foundation.RulesEngine.Redis --version 26.5.20.1
NuGet\Install-Package Galosys.Foundation.RulesEngine.Redis -Version 26.5.20.1
<PackageReference Include="Galosys.Foundation.RulesEngine.Redis" Version="26.5.20.1" />
<PackageVersion Include="Galosys.Foundation.RulesEngine.Redis" Version="26.5.20.1" />Directory.Packages.props
<PackageReference Include="Galosys.Foundation.RulesEngine.Redis" />Project file
paket add Galosys.Foundation.RulesEngine.Redis --version 26.5.20.1
#r "nuget: Galosys.Foundation.RulesEngine.Redis, 26.5.20.1"
#:package Galosys.Foundation.RulesEngine.Redis@26.5.20.1
#addin nuget:?package=Galosys.Foundation.RulesEngine.Redis&version=26.5.20.1Install as a Cake Addin
#tool nuget:?package=Galosys.Foundation.RulesEngine.Redis&version=26.5.20.1Install as a Cake Tool
规则引擎 Redis Pub/Sub 热更新广播模块,支持多实例部署时规则变更的跨实例同步通知。
依赖:
Galosys.Foundation.RulesEngine(必选)+Galosys.Foundation.Redis(必选)
// Program.cs
services.AddRuleEngine(configuration);
services.AddRedisRuleChangeNotifier(configuration);
需先注册 Redis 实现(FreeRedis 或 StackExchange.Redis):
services.AddFreeRedis(configuration); // 或 services.AddStackExchangeRedis(configuration);
services.AddRuleEngine(configuration);
services.AddRedisRuleChangeNotifier(configuration);
{
"Rules": {
"Redis": {
"Channel": "rules:change"
}
}
}
| 配置项 | 默认值 | 说明 |
|---|---|---|
Rules:Redis:Channel |
"rules:change" |
Pub/Sub 频道名 |
管理后台修改规则后,通知所有实例刷新缓存:
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 | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.