mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-05-05 13:40:44 +08:00
fix(api-key): reset rate limit usage cache
This commit is contained in:
@@ -565,6 +565,22 @@ func (s *stubAdminService) AdminUpdateAPIKeyGroupID(ctx context.Context, keyID i
|
||||
return nil, service.ErrAPIKeyNotFound
|
||||
}
|
||||
|
||||
func (s *stubAdminService) AdminResetAPIKeyRateLimitUsage(ctx context.Context, keyID int64) (*service.APIKey, error) {
|
||||
for i := range s.apiKeys {
|
||||
if s.apiKeys[i].ID == keyID {
|
||||
s.apiKeys[i].Usage5h = 0
|
||||
s.apiKeys[i].Usage1d = 0
|
||||
s.apiKeys[i].Usage7d = 0
|
||||
s.apiKeys[i].Window5hStart = nil
|
||||
s.apiKeys[i].Window1dStart = nil
|
||||
s.apiKeys[i].Window7dStart = nil
|
||||
k := s.apiKeys[i]
|
||||
return &k, nil
|
||||
}
|
||||
}
|
||||
return nil, service.ErrAPIKeyNotFound
|
||||
}
|
||||
|
||||
func (s *stubAdminService) ResetAccountQuota(ctx context.Context, id int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user