mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-06 01:07:06 +08:00
support multi transaction
This commit is contained in:
12
router.go
12
router.go
@@ -1,23 +1,27 @@
|
||||
package godis
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
var cmdTable = make(map[string]*command)
|
||||
|
||||
type command struct {
|
||||
executor ExecFunc
|
||||
prepare PreFunc // return related keys and rollback command
|
||||
arity int // allow number of args, arity < 0 means len(args) >= -arity
|
||||
prepare PreFunc // return related keys command
|
||||
undo UndoFunc
|
||||
arity int // allow number of args, arity < 0 means len(args) >= -arity
|
||||
}
|
||||
|
||||
// RegisterCommand registers a new command
|
||||
// arity means allowed number of cmdArgs, arity < 0 means len(args) >= -arity.
|
||||
// for example: the arity of `get` is 2, `mget` is -2
|
||||
func RegisterCommand(name string, executor ExecFunc, prepare PreFunc, arity int) {
|
||||
func RegisterCommand(name string, executor ExecFunc, prepare PreFunc, rollback UndoFunc, arity int) {
|
||||
name = strings.ToLower(name)
|
||||
cmdTable[name] = &command{
|
||||
executor: executor,
|
||||
prepare: prepare,
|
||||
undo: rollback,
|
||||
arity: arity,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user