fix: 参数配置redis查询取值异常
This commit is contained in:
@@ -12,8 +12,8 @@ import (
|
|||||||
func SessionHeader() gin.HandlerFunc {
|
func SessionHeader() gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
// 读取登录生成的会话token
|
// 读取登录生成的会话token
|
||||||
token, err := redis.Get("", "session_token")
|
token, _ := redis.Get("", "session_token")
|
||||||
if token != "" || err == nil {
|
if token != "" {
|
||||||
// 过期时间单位秒 配置1800是半小时
|
// 过期时间单位秒 配置1800是半小时
|
||||||
expireTime := time.Duration(int64(libConfig.GetExpiresFromConfig())) * time.Second
|
expireTime := time.Duration(int64(libConfig.GetExpiresFromConfig())) * time.Second
|
||||||
redis.SetByExpire("", "session_token", token, expireTime)
|
redis.SetByExpire("", "session_token", token, expireTime)
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ func (r *SysConfigImpl) SelectConfigList(sysConfig model.SysConfig) []model.SysC
|
|||||||
func (r *SysConfigImpl) SelectConfigValueByKey(configKey string) string {
|
func (r *SysConfigImpl) SelectConfigValueByKey(configKey string) string {
|
||||||
cacheKey := r.getCacheKey(configKey)
|
cacheKey := r.getCacheKey(configKey)
|
||||||
// 从缓存中读取
|
// 从缓存中读取
|
||||||
cacheValue, err := redis.Get("", cacheKey)
|
cacheValue, _ := redis.Get("", cacheKey)
|
||||||
if cacheValue != "" || err != nil {
|
if cacheValue != "" {
|
||||||
return cacheValue
|
return cacheValue
|
||||||
}
|
}
|
||||||
// 无缓存时读取数据放入缓存中
|
// 无缓存时读取数据放入缓存中
|
||||||
|
|||||||
Reference in New Issue
Block a user