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)
| 79 | // Quota is maintained by atomic quota delta paths and must not be overwritten |
| 80 | // by stale user snapshots from profile/settings updates. |
| 81 | func 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 |
| 101 | func GetUserCache(userId int) (userCache *UserBase, err error) { |
no test coverage detected