(id int, key string, quota int)
| 287 | } |
| 288 | |
| 289 | func 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 | |
| 308 | func increaseTokenQuota(id int, quota int) (err error) { |
| 309 | err = DB.Model(&Token{}).Where("id = ?", id).Updates( |
no test coverage detected