mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08: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>
6 lines
253 B
Lua
6 lines
253 B
Lua
-- 清理过期成员后返回反向索引的成员数量
|
|
-- KEYS[1] = client_affinity_rev:{groupID}:{accountID}
|
|
-- ARGV[1] = 过期阈值时间戳 (now - ttl)
|
|
redis.call('ZREMRANGEBYSCORE', KEYS[1], '-inf', ARGV[1])
|
|
return redis.call('ZCARD', KEYS[1])
|