forked from flashmob/go-guerrilla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redis_generic.go
45 lines (35 loc) · 1005 Bytes
/
redis_generic.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
package backends
import (
"net"
"time"
)
func init() {
RedisDialer = func(network, address string, options ...RedisDialOption) (RedisConn, error) {
return new(RedisMockConn), nil
}
}
// RedisConn interface provides a generic way to access Redis via drivers
type RedisConn interface {
Close() error
Do(commandName string, args ...interface{}) (reply interface{}, err error)
}
type RedisMockConn struct{}
func (m *RedisMockConn) Close() error {
return nil
}
func (m *RedisMockConn) Do(commandName string, args ...interface{}) (reply interface{}, err error) {
Log().Info("redis mock driver command: ", commandName)
return nil, nil
}
type dialOptions struct {
readTimeout time.Duration
writeTimeout time.Duration
dial func(network, addr string) (net.Conn, error)
db int
password string
}
type RedisDialOption struct {
f func(*dialOptions)
}
type redisDial func(network, address string, options ...RedisDialOption) (RedisConn, error)
var RedisDialer redisDial