타입 이름 변경
This commit is contained in:
24
redis.go
24
redis.go
@ -66,20 +66,20 @@ func NewRedisClient(uri string) (*redis.Client, error) {
|
|||||||
return redis.NewClient(option), nil
|
return redis.NewClient(option), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetOption = string
|
type RedisonSetOption = string
|
||||||
type GetOption = [2]any
|
type RedisonGetOption = [2]any
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// JSONSET command Options
|
// JSONSET command Options
|
||||||
SetOptionNX SetOption = "NX"
|
RedisonSetOptionNX RedisonSetOption = "NX"
|
||||||
SetOptionXX SetOption = "XX"
|
RedisonSetOptionXX RedisonSetOption = "XX"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
GetOptionSPACE = GetOption{"SPACE", " "}
|
RedisonGetOptionSPACE = RedisonGetOption{"SPACE", " "}
|
||||||
GetOptionINDENT = GetOption{"INDENT", "\t"}
|
RedisonGetOptionINDENT = RedisonGetOption{"INDENT", "\t"}
|
||||||
GetOptionNEWLINE = GetOption{"NEWLINE", "\n"}
|
RedisonGetOptionNEWLINE = RedisonGetOption{"NEWLINE", "\n"}
|
||||||
GetOptionNOESCAPE = GetOption{"NOESCAPE", ""}
|
RedisonGetOptionNOESCAPE = RedisonGetOption{"NOESCAPE", ""}
|
||||||
)
|
)
|
||||||
|
|
||||||
// gocommon으로 옮길 거
|
// gocommon으로 옮길 거
|
||||||
@ -146,7 +146,7 @@ func (rh *RedisonHandler) JSONMSet(key string, kv map[string]any) error {
|
|||||||
return rh.JSONMSetRel(key, "", kv)
|
return rh.JSONMSetRel(key, "", kv)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rh *RedisonHandler) jsonSetMergeJSONSet(cmd, key, path string, obj any, opts ...SetOption) (bool, error) {
|
func (rh *RedisonHandler) jsonSetMergeJSONSet(cmd, key, path string, obj any, opts ...RedisonSetOption) (bool, error) {
|
||||||
b, err := json.Marshal(obj)
|
b, err := json.Marshal(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@ -170,15 +170,15 @@ func (rh *RedisonHandler) jsonSetMergeJSONSet(cmd, key, path string, obj any, op
|
|||||||
return res.(string) == "OK", nil
|
return res.(string) == "OK", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rh *RedisonHandler) JSONSet(key, path string, obj any, opts ...SetOption) (bool, error) {
|
func (rh *RedisonHandler) JSONSet(key, path string, obj any, opts ...RedisonSetOption) (bool, error) {
|
||||||
return rh.jsonSetMergeJSONSet("JSON.SET", key, path, obj, opts...)
|
return rh.jsonSetMergeJSONSet("JSON.SET", key, path, obj, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rh *RedisonHandler) JSONMerge(key, path string, obj any, opts ...SetOption) (bool, error) {
|
func (rh *RedisonHandler) JSONMerge(key, path string, obj any, opts ...RedisonSetOption) (bool, error) {
|
||||||
return rh.jsonSetMergeJSONSet("JSON.MERGE", key, path, obj, opts...)
|
return rh.jsonSetMergeJSONSet("JSON.MERGE", key, path, obj, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rh *RedisonHandler) JSONGet(key, path string, opts ...GetOption) (res any, err error) {
|
func (rh *RedisonHandler) JSONGet(key, path string, opts ...RedisonGetOption) (res any, err error) {
|
||||||
args := appendArgs[string]([]any{
|
args := appendArgs[string]([]any{
|
||||||
"JSON.GET",
|
"JSON.GET",
|
||||||
key,
|
key,
|
||||||
|
|||||||
Reference in New Issue
Block a user