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

Function GetTokenById

model/token.go:151–166  ·  view source on GitHub ↗
(id int)

Source from the content-addressed store, hash-verified

149}
150
151func GetTokenById(id int) (*Token, error) {
152 if id == 0 {
153 return nil, errors.New("id 为空!")
154 }
155 token := Token{Id: id}
156 var err error = nil
157 err = DB.First(&token, "id = ?", id).Error
158 if shouldUpdateRedis(true, err) {
159 gopool.Go(func() {
160 if err := cacheSetToken(token); err != nil {
161 common.SysError("failed to update user status cache: " + err.Error())
162 }
163 })
164 }
165 return &token, err
166}
167
168func GetTokenByKey(key string, fromDB bool) (token *Token, err error) {
169 defer func() {

Callers 3

GetSubscriptionFunction · 0.92
GetUsageFunction · 0.92
DisableModelLimitsFunction · 0.85

Calls 4

SysErrorFunction · 0.92
shouldUpdateRedisFunction · 0.85
cacheSetTokenFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected