mirror of
https://github.com/EchoVault/SugarDB.git
synced 2025-10-25 17:00:23 +08:00
Renamed *AccessKey type to better represent the response on *KeyExtractionFunc types
This commit is contained in:
@@ -20,20 +20,20 @@ import (
|
||||
"github.com/echovault/echovault/internal"
|
||||
)
|
||||
|
||||
func setKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func setKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 || len(cmd) > 7 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func msetKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func msetKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd[1:])%2 != 0 {
|
||||
return internal.AccessKeys{}, errors.New("each key must be paired with a value")
|
||||
return internal.KeyExtractionFuncResult{}, errors.New("each key must be paired with a value")
|
||||
}
|
||||
var keys []string
|
||||
for i, key := range cmd[1:] {
|
||||
@@ -41,95 +41,95 @@ func msetKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: keys,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func getKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func mgetKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func mgetKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func delKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func delKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func persistKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func persistKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func expireTimeKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func expireTimeKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ttlKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func ttlKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func expireKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func expireKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 || len(cmd) > 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func expireAtKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func expireAtKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 || len(cmd) > 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
|
||||
Reference in New Issue
Block a user