Release / update-version (push) Has been cancelled
Release / build-frontend (push) Has been cancelled
Release / release (push) Has been cancelled
Release / sync-version-file (push) Has been cancelled
CI / shell (push) Canceled after 0s
CI / test (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
Security Scan / backend-security (push) Canceled after 0s
Security Scan / frontend-security (push) Canceled after 0s
18 lines
655 B
Go
18 lines
655 B
Go
package service
|
||
|
||
import "context"
|
||
|
||
// RPMCache RPM 计数器缓存接口
|
||
// 用于 Anthropic OAuth/SetupToken 账号的每分钟请求数限制
|
||
type RPMCache interface {
|
||
// IncrementRPM 原子递增并返回当前分钟的计数
|
||
// 使用 Redis 服务器时间确定 minute key,避免多实例时钟偏差
|
||
IncrementRPM(ctx context.Context, accountID int64) (count int, err error)
|
||
|
||
// GetRPM 获取当前分钟的 RPM 计数
|
||
GetRPM(ctx context.Context, accountID int64) (count int, err error)
|
||
|
||
// GetRPMBatch 批量获取多个账号的 RPM 计数(使用 Pipeline)
|
||
GetRPMBatch(ctx context.Context, accountIDs []int64) (map[int64]int, error)
|
||
}
|