mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-06 16:04:24 +00:00
- Separate clientAffinityTTL (24h) from stickySessionTTL (1h) - Atomic Lua dual-write for forward (client→accounts) and reverse (account→clients) affinity indexes with lazy expiry cleanup - Extract Lua scripts to standalone .lua files with //go:embed - Add filterByMinAffinityCount to Layer 1 & 2 scheduling so new clients are routed to accounts with fewest existing affinities - Skip Redis query when no affinity-enabled accounts exist (zero overhead for non-affinity users) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9 lines
366 B
Lua
9 lines
366 B
Lua
-- 原子双删正向+反向索引
|
|
-- KEYS[1] = client_affinity:{groupID}:{clientID} (正向)
|
|
-- KEYS[2] = client_affinity_rev:{groupID}:{accountID} (反向)
|
|
-- ARGV[1] = accountID (正向索引中要删除的成员)
|
|
-- ARGV[2] = clientID (反向索引中要删除的成员)
|
|
redis.call('ZREM', KEYS[1], ARGV[1])
|
|
redis.call('ZREM', KEYS[2], ARGV[2])
|
|
return 1
|