MCPcopy Create free account
hub / github.com/QuantumNous/new-api / updateUserCache

Function updateUserCache

model/user_cache.go:81–98  ·  view source on GitHub ↗

updateUserCache refreshes non-quota user cache fields. Quota is maintained by atomic quota delta paths and must not be overwritten by stale user snapshots from profile/settings updates.

(user User)

Source from the content-addressed store, hash-verified

79// Quota is maintained by atomic quota delta paths and must not be overwritten
80// by stale user snapshots from profile/settings updates.
81func updateUserCache(user User) error {
82 if !common.RedisEnabled {
83 return nil
84 }
85 if err := updateUserGroupCache(user.Id, user.Group); err != nil {
86 return err
87 }
88 if err := updateUserEmailCache(user.Id, user.Email); err != nil {
89 return err
90 }
91 if err := updateUserStatusCache(user.Id, user.Status == common.UserStatusEnabled); err != nil {
92 return err
93 }
94 if err := updateUserNameCache(user.Id, user.Username); err != nil {
95 return err
96 }
97 return updateUserSettingCache(user.Id, user.Setting)
98}
99
100// GetUserCache gets complete user cache from hash
101func GetUserCache(userId int) (userCache *UserBase, err error) {

Callers 4

BindEmailToUserFunction · 0.85
UpdateMethod · 0.85
EditMethod · 0.85
ClearBindingMethod · 0.85

Calls 5

updateUserGroupCacheFunction · 0.85
updateUserEmailCacheFunction · 0.85
updateUserStatusCacheFunction · 0.85
updateUserNameCacheFunction · 0.85
updateUserSettingCacheFunction · 0.85

Tested by

no test coverage detected