feat: add per-account subscription result cache with LRU (Gap 5.4)

Implements RouteResultCache with fixed-capacity LRU eviction and atomic
generation-based invalidation (Go ref: client.go routeCache, maxResultCacheSize=8192).
Fixes AccountGoParityTests namespace ambiguity introduced by new test file.
This commit is contained in:
Joseph Doherty
2026-02-25 11:31:17 -05:00
parent 0e1a39df96
commit 1a1e99f7d8
3 changed files with 352 additions and 3 deletions

View File

@@ -3,6 +3,7 @@
using NATS.Server.Auth;
using NATS.Server.Imports;
using NATS.Server.Subscriptions;
namespace NATS.Server.Tests.Auth;
@@ -27,7 +28,7 @@ public class AccountGoParityTests
using var accB = new Account("B");
// Add subscriptions to account A's SubList
var subA = new Subscriptions.Subscription { Subject = "foo", Sid = "1" };
var subA = new Subscription { Subject = "foo", Sid = "1" };
accA.SubList.Insert(subA);
// Account B should not see account A's subscriptions
@@ -51,8 +52,8 @@ public class AccountGoParityTests
// Go: TestAccountWildcardRouteMapping — wildcards work per-account.
using var acc = new Account("TEST");
var sub1 = new Subscriptions.Subscription { Subject = "orders.*", Sid = "1" };
var sub2 = new Subscriptions.Subscription { Subject = "orders.>", Sid = "2" };
var sub1 = new Subscription { Subject = "orders.*", Sid = "1" };
var sub2 = new Subscription { Subject = "orders.>", Sid = "2" };
acc.SubList.Insert(sub1);
acc.SubList.Insert(sub2);