MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / IncreaseTokenQuota

Function IncreaseTokenQuota

model/token.go:289–306  ·  view source on GitHub ↗
(id int, key string, quota int)

Source from the content-addressed store, hash-verified

287}
288
289func IncreaseTokenQuota(id int, key string, quota int) (err error) {
290 if quota < 0 {
291 return errors.New("quota 不能为负数!")
292 }
293 if common.RedisEnabled {
294 gopool.Go(func() {
295 err := cacheIncrTokenQuota(key, int64(quota))
296 if err != nil {
297 common.SysError("failed to increase token quota: " + err.Error())
298 }
299 })
300 }
301 if common.BatchUpdateEnabled {
302 addNewRecord(BatchUpdateTypeTokenQuota, id, quota)
303 return nil
304 }
305 return increaseTokenQuota(id, quota)
306}
307
308func increaseTokenQuota(id int, quota int) (err error) {
309 err = DB.Model(&Token{}).Where("id = ?", id).Updates(

Callers 1

PostConsumeQuotaFunction · 0.92

Calls 5

SysErrorFunction · 0.92
cacheIncrTokenQuotaFunction · 0.85
addNewRecordFunction · 0.85
increaseTokenQuotaFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected