mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-01-03 13:16:35 +08:00
refactor: db/redis/mongo连接代码包独立
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func (r *Redis) GetListValue(rc *req.Ctx) {
|
||||
ri, key := r.checkKeyAndGetRedisIns(rc)
|
||||
ri, key := r.checkKeyAndGetRedisConn(rc)
|
||||
ctx := context.TODO()
|
||||
cmdable := ri.GetCmdable()
|
||||
|
||||
@@ -34,7 +34,7 @@ func (r *Redis) Lrem(rc *req.Ctx) {
|
||||
option := new(form.LRemOption)
|
||||
ginx.BindJsonAndValid(g, option)
|
||||
|
||||
cmd := r.getRedisIns(rc).GetCmdable()
|
||||
cmd := r.getRedisConn(rc).GetCmdable()
|
||||
res, err := cmd.LRem(context.TODO(), option.Key, int64(option.Count), option.Member).Result()
|
||||
biz.ErrIsNilAppendErr(err, "lrem失败: %s")
|
||||
rc.ResData = res
|
||||
@@ -45,7 +45,7 @@ func (r *Redis) SaveListValue(rc *req.Ctx) {
|
||||
listValue := new(form.ListValue)
|
||||
ginx.BindJsonAndValid(g, listValue)
|
||||
|
||||
cmd := r.getRedisIns(rc).GetCmdable()
|
||||
cmd := r.getRedisConn(rc).GetCmdable()
|
||||
|
||||
key := listValue.Key
|
||||
ctx := context.TODO()
|
||||
@@ -59,7 +59,7 @@ func (r *Redis) SetListValue(rc *req.Ctx) {
|
||||
listSetValue := new(form.ListSetValue)
|
||||
ginx.BindJsonAndValid(g, listSetValue)
|
||||
|
||||
ri := r.getRedisIns(rc)
|
||||
ri := r.getRedisConn(rc)
|
||||
|
||||
_, err := ri.GetCmdable().LSet(context.TODO(), listSetValue.Key, listSetValue.Index, listSetValue.Value).Result()
|
||||
biz.ErrIsNilAppendErr(err, "list set失败: %s")
|
||||
|
||||
Reference in New Issue
Block a user