The rest of the files needed to pass Redis tests
This commit is contained in:
parent
eb8e5b33a9
commit
999a268ca8
3 changed files with 17 additions and 3 deletions
1
cache/cache.go
vendored
1
cache/cache.go
vendored
|
@ -17,6 +17,7 @@ import (
|
|||
var (
|
||||
drivers = make(map[string]Driver)
|
||||
ErrTxDone = errors.New("cache: Transaction has already been committed or rolled back")
|
||||
ErrTxConflict = errors.New("cache: Commit interrupted, update transaction and repeat")
|
||||
)
|
||||
|
||||
type Driver interface {
|
||||
|
|
13
cache/redis/redis.go
vendored
13
cache/redis/redis.go
vendored
|
@ -106,6 +106,7 @@ func (tx *Tx) initiateWrite() error {
|
|||
return cache.ErrTxDone
|
||||
}
|
||||
if tx.multi != true {
|
||||
tx.multi = true
|
||||
return tx.Send("MULTI")
|
||||
}
|
||||
return nil
|
||||
|
@ -126,7 +127,11 @@ func (tx *Tx) Commit() error {
|
|||
return cache.ErrTxDone
|
||||
}
|
||||
if tx.multi == true {
|
||||
_, err := tx.Do("EXEC")
|
||||
execResponse, err := tx.Do("EXEC")
|
||||
if execResponse == nil {
|
||||
tx.multi = false
|
||||
return cache.ErrTxConflict
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -139,7 +144,11 @@ func (tx *Tx) Rollback() error {
|
|||
if tx.done {
|
||||
return cache.ErrTxDone
|
||||
}
|
||||
// Redis doesn't need to do anything. Exec is atomic.
|
||||
// Undoes watches and multi
|
||||
if _, err := tx.Do("DISCARD") ; err != nil {
|
||||
return err
|
||||
}
|
||||
tx.multi = false
|
||||
tx.close()
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -12,7 +12,11 @@
|
|||
"prefix": "test:",
|
||||
|
||||
"max_idle_conn": 3,
|
||||
"idle_timeout": "240s"
|
||||
"idle_timeout": "240s",
|
||||
|
||||
"network": "tcp",
|
||||
"schema": "schema",
|
||||
"encoding": "encoding"
|
||||
},
|
||||
|
||||
"storage": {
|
||||
|
|
Loading…
Reference in a new issue