forked from forgejo/forgejo
Fix get system setting bug when enabled redis cache (#22298)
backport #22295, fix #22281 Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
parent
f1e07d8c87
commit
0697075547
5 changed files with 16 additions and 53 deletions
|
@ -54,13 +54,13 @@ func genSettingCacheKey(userID int64, key string) string {
|
|||
}
|
||||
|
||||
// GetSetting returns the setting value via the key
|
||||
func GetSetting(uid int64, key string) (*Setting, error) {
|
||||
return cache.Get(genSettingCacheKey(uid, key), func() (*Setting, error) {
|
||||
func GetSetting(uid int64, key string) (string, error) {
|
||||
return cache.GetString(genSettingCacheKey(uid, key), func() (string, error) {
|
||||
res, err := GetSettingNoCache(uid, key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
return res, nil
|
||||
return res.SettingValue, nil
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ func SetUserSetting(userID int64, key, value string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
_, err := cache.Set(genSettingCacheKey(userID, key), func() (string, error) {
|
||||
_, err := cache.GetString(genSettingCacheKey(userID, key), func() (string, error) {
|
||||
return value, upsertUserSettingValue(userID, key, value)
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue