1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-23 13:42:25 +08:00

Compare commits

...

3 Commits

Author SHA1 Message Date
houseme
5ac748433d Merge e7ff8d90ed into 06719f77b7 2023-09-02 10:50:42 +08:00
houseme
e7ff8d90ed fix 2023-08-25 20:05:15 +08:00
houseme
5467bc6245 feat: redis deprecated 2023-08-25 19:57:35 +08:00
2 changed files with 8 additions and 6 deletions

View File

@@ -10,7 +10,7 @@ jobs:
golangci:
strategy:
matrix:
go-version: [ '1.16','1.17','1.18','1.19','1.20' ]
go-version: [ '1.16','1.17','1.18','1.19','1.20','1.21' ]
name: golangci-lint
runs-on: ubuntu-latest
steps:
@@ -42,7 +42,7 @@ jobs:
# strategy set
strategy:
matrix:
go: [ '1.16','1.17','1.18','1.19','1.20' ]
go: [ '1.16','1.17','1.18','1.19','1.20','1.21' ]
steps:
- uses: actions/checkout@v3

10
cache/redis.go vendored
View File

@@ -8,6 +8,8 @@ import (
)
// Redis .redis cache
// Deprecated: user defined implementation cache、ContextCache interface
// The implementation was officially removed in v2.1.6
type Redis struct {
ctx context.Context
conn redis.UniversalClient
@@ -35,12 +37,12 @@ func NewRedis(ctx context.Context, opts *RedisOpts) *Redis {
return &Redis{ctx: ctx, conn: conn}
}
// SetConn 设置conn
// SetConn 设置 conn
func (r *Redis) SetConn(conn redis.UniversalClient) {
r.conn = conn
}
// SetRedisCtx 设置redis ctx 参数
// SetRedisCtx 设置 redis ctx 参数
func (r *Redis) SetRedisCtx(ctx context.Context) {
r.ctx = ctx
}
@@ -69,12 +71,12 @@ func (r *Redis) SetContext(ctx context.Context, key string, val interface{}, tim
return r.conn.SetEX(ctx, key, val, timeout).Err()
}
// IsExist 判断key是否存在
// IsExist 判断 key 是否存在
func (r *Redis) IsExist(key string) bool {
return r.IsExistContext(r.ctx, key)
}
// IsExistContext 判断key是否存在
// IsExistContext 判断 key 是否存在
func (r *Redis) IsExistContext(ctx context.Context, key string) bool {
result, _ := r.conn.Exists(ctx, key).Result()