Skip to content

Commit 420311c

Browse files
修复 redis 编码错误
1 parent 26c6bff commit 420311c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pkg/utils/config_redis.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (r *ConfigRedis) Put(key string, value string, ttl time.Duration) error {
4141
if ttl != TtlKeep {
4242
builder.Ex(ttl)
4343
}
44-
return r.client.Do(r.ctx, builder.Nx().Build()).Error()
44+
return r.client.Do(r.ctx, builder.Build()).Error()
4545
}
4646

4747
func (r *ConfigRedis) Get(key string) (string, error) {
@@ -53,7 +53,11 @@ func (r *ConfigRedis) Get(key string) (string, error) {
5353
}
5454

5555
func (r *ConfigRedis) Delete(key string) error {
56-
return r.client.Do(r.ctx, r.client.B().Decr().Key(key).Build()).Error()
56+
err := r.client.Do(r.ctx, r.client.B().Del().Key(key).Build()).Error()
57+
if err != nil && errors.Is(err, valkey.Nil) {
58+
return os.ErrNotExist
59+
}
60+
return nil
5761
}
5862

5963
func (r *ConfigRedis) Close() error {

0 commit comments

Comments
 (0)