修复 redis 获取
This commit is contained in:
parent
5a9f16d1ae
commit
eed2c1ccf5
4
db/cache/redis.go
vendored
4
db/cache/redis.go
vendored
@ -4,6 +4,7 @@ package cache
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -35,6 +36,9 @@ func (r *RedisCache) Del(k []byte) error {
|
|||||||
func (r *RedisCache) Get(k []byte) ([]byte, error) {
|
func (r *RedisCache) Get(k []byte) ([]byte, error) {
|
||||||
value, err := r.c.Get(context.Background(), string(k)).Bytes()
|
value, err := r.c.Get(context.Background(), string(k)).Bytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, redis.Nil) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
return nil, fmt.Errorf("RedisCache.Get: %w", err)
|
return nil, fmt.Errorf("RedisCache.Get: %w", err)
|
||||||
}
|
}
|
||||||
return value, nil
|
return value, nil
|
||||||
|
@ -33,7 +33,6 @@ type TokenClaims struct {
|
|||||||
type Captcha struct {
|
type Captcha struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
SiteKey string `json:"siteKey"`
|
SiteKey string `json:"siteKey"`
|
||||||
ServerName string `json:"serverName"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserInfo struct {
|
type UserInfo struct {
|
||||||
@ -62,6 +61,7 @@ type ChangeName struct {
|
|||||||
type Config struct {
|
type Config struct {
|
||||||
Captcha Captcha `json:"captcha"`
|
Captcha Captcha `json:"captcha"`
|
||||||
AllowChangeName bool
|
AllowChangeName bool
|
||||||
|
ServerName string `json:"serverName"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type EditUser struct {
|
type EditUser struct {
|
||||||
|
@ -17,8 +17,8 @@ func (w *WebService) GetConfig(ctx context.Context) model.Config {
|
|||||||
Captcha: model.Captcha{
|
Captcha: model.Captcha{
|
||||||
Type: w.config.Captcha.Type,
|
Type: w.config.Captcha.Type,
|
||||||
SiteKey: w.config.Captcha.SiteKey,
|
SiteKey: w.config.Captcha.SiteKey,
|
||||||
ServerName: w.config.ServerName,
|
|
||||||
},
|
},
|
||||||
|
ServerName: w.config.ServerName,
|
||||||
AllowChangeName: !w.config.OfflineUUID,
|
AllowChangeName: !w.config.OfflineUUID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user