-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhandler.go
118 lines (105 loc) · 5.21 KB
/
handler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright (C) 2022 The go-redis Authors All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package redis
// ConnectionManagementCommandHandler represents a hander interface for connection management commands.
type ConnectionManagementCommandHandler interface {
Ping(conn *Conn, arg string) (*Message, error)
Echo(conn *Conn, arg string) (*Message, error)
Select(conn *Conn, index int) (*Message, error)
Quit(conn *Conn) (*Message, error)
}
// ServerManagementCommandHandler represents a hander interface for server management commands.
type ServerManagementCommandHandler interface {
ConfigSet(conn *Conn, params map[string]string) (*Message, error)
ConfigGet(conn *Conn, keys []string) (*Message, error)
}
// GenericCommandHandler represents a hander interface for genelic commands.
type GenericCommandHandler interface {
Del(conn *Conn, keys []string) (*Message, error)
Exists(conn *Conn, keys []string) (*Message, error)
Expire(conn *Conn, key string, opt ExpireOption) (*Message, error)
Keys(conn *Conn, pattern string) (*Message, error)
Rename(conn *Conn, key string, newkey string, opt RenameOption) (*Message, error)
Type(conn *Conn, key string) (*Message, error)
TTL(conn *Conn, key string) (*Message, error)
Scan(conn *Conn, cursor int, opt ScanOption) (*Message, error)
}
// StringCommandHandler represents a core command hander interface for string commands.
// APPEND, DECR, DECRBY, GETRANGE, GETSET, INCR, INCRBY, MGET, MSET, MSETNX, SETRANGE, STRLEN commands are implemented by the StringCommandHandler.
type StringCommandHandler interface {
// Set represents a handler interface for SET, SETNX, SETEX, PSETEX, MSET and MSETNX commands.
Set(conn *Conn, key string, val string, opt SetOption) (*Message, error)
// Get represents a handler interface for GET and MGET commands.
Get(conn *Conn, key string) (*Message, error)
}
// HashCommandHandler represents a core command hander interface for hash commands.
// HMSET and HMGET commands are implemented by the HashCommandHandler.
type HashCommandHandler interface {
// HDel represents a handler interface for HDEL command.
HDel(conn *Conn, key string, fields []string) (*Message, error)
// HSet represents a handler interface for HSET and HSETNX commands.
HSet(conn *Conn, key string, field string, val string, opt HSetOption) (*Message, error)
// HGet represents a handler interface for HGET command.
HGet(conn *Conn, key string, field string) (*Message, error)
// HGetAll represents a handler interface for HGETALL command.
HGetAll(conn *Conn, key string) (*Message, error)
}
// ListCommandHandler represents a core command hander interface for list commands.
type ListCommandHandler interface {
LPush(conn *Conn, key string, elements []string, opt PushOption) (*Message, error)
RPush(conn *Conn, key string, elements []string, opt PushOption) (*Message, error)
LPop(conn *Conn, key string, count int) (*Message, error)
RPop(conn *Conn, key string, count int) (*Message, error)
LRange(conn *Conn, key string, start int, stop int) (*Message, error)
LIndex(conn *Conn, key string, index int) (*Message, error)
LLen(conn *Conn, key string) (*Message, error)
}
// SetCommandHandler represents a core command hander interface for set commands.
type SetCommandHandler interface {
SAdd(conn *Conn, key string, members []string) (*Message, error)
SMembers(conn *Conn, key string) (*Message, error)
SRem(conn *Conn, key string, members []string) (*Message, error)
}
// ZSetMember represents a parameter for ZSetCommandHandler.
type ZSetMember struct {
Score float64
Member string
}
// ZSetCommandHandler represents a core command hander interface for zset commands.
type ZSetCommandHandler interface {
ZAdd(conn *Conn, key string, members []*ZSetMember, opt ZAddOption) (*Message, error)
ZRange(conn *Conn, key string, start int, stop int, opt ZRangeOption) (*Message, error)
ZRangeByScore(conn *Conn, key string, min float64, max float64, opt ZRangeOption) (*Message, error)
ZRem(conn *Conn, key string, members []string) (*Message, error)
ZScore(conn *Conn, key string, member string) (*Message, error)
ZIncBy(conn *Conn, key string, inc float64, member string) (*Message, error)
}
// AuthCommandHandler represents a hander interface for authentication commands.
type AuthCommandHandler interface {
Auth(conn *Conn, username string, password string) (*Message, error)
}
// UserCommandHandler represents a command hander interface for user commands.
type UserCommandHandler interface {
GenericCommandHandler
StringCommandHandler
HashCommandHandler
ListCommandHandler
SetCommandHandler
ZSetCommandHandler
}
// SystemCommandHandler represents a hander interface for system commands.
type SystemCommandHandler interface {
ConnectionManagementCommandHandler
ServerManagementCommandHandler
}