MCPcopy
hub / github.com/songquanpeng/one-api / batchUpdate

Function batchUpdate

model/utils.go:48–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46}
47
48func batchUpdate() {
49 logger.SysLog("batch update started")
50 for i := 0; i < BatchUpdateTypeCount; i++ {
51 batchUpdateLocks[i].Lock()
52 store := batchUpdateStores[i]
53 batchUpdateStores[i] = make(map[int]int64)
54 batchUpdateLocks[i].Unlock()
55 // TODO: maybe we can combine updates with same key?
56 for key, value := range store {
57 switch i {
58 case BatchUpdateTypeUserQuota:
59 err := increaseUserQuota(key, value)
60 if err != nil {
61 logger.SysError("failed to batch update user quota: " + err.Error())
62 }
63 case BatchUpdateTypeTokenQuota:
64 err := increaseTokenQuota(key, value)
65 if err != nil {
66 logger.SysError("failed to batch update token quota: " + err.Error())
67 }
68 case BatchUpdateTypeUsedQuota:
69 updateUserUsedQuota(key, value)
70 case BatchUpdateTypeRequestCount:
71 updateUserRequestCount(key, int(value))
72 case BatchUpdateTypeChannelUsedQuota:
73 updateChannelUsedQuota(key, value)
74 }
75 }
76 }
77 logger.SysLog("batch update finished")
78}

Callers 1

InitBatchUpdaterFunction · 0.85

Calls 7

SysLogFunction · 0.92
SysErrorFunction · 0.92
increaseUserQuotaFunction · 0.85
increaseTokenQuotaFunction · 0.85
updateUserUsedQuotaFunction · 0.85
updateUserRequestCountFunction · 0.85
updateChannelUsedQuotaFunction · 0.85

Tested by

no test coverage detected