Skip to content
This repository has been archived by the owner on Mar 19, 2018. It is now read-only.

making redis wrapper handle nil timer. adding missing regigo api passthroughs #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,26 @@ func Dial(network, address string) (Conn, error) {
}

func (c *conn) DoTimer(t miniprofiler.Timer, commandName string, args ...interface{}) (reply interface{}, err error) {
t.StepCustomTiming("redis", "do", format(commandName, args...), func() {
f := func() {
reply, err = c.Conn.Do(commandName, args...)
})
}
if t != nil {
t.StepCustomTiming("redis", "do", format(commandName, args...), f)
} else {
f()
}
return
}

func (c *conn) SendTimer(t miniprofiler.Timer, commandName string, args ...interface{}) (err error) {
t.StepCustomTiming("redis", "send", format(commandName, args...), func() {
f := func() {
err = c.Conn.Send(commandName, args...)
})
}
if t != nil {
t.StepCustomTiming("redis", "send", format(commandName, args...), f)
} else {
f()
}
return
}

Expand All @@ -96,21 +106,34 @@ func format(commandName string, args ...interface{}) string {
}

var Bool = redis.Bool
var ByteSlices = redis.ByteSlices
var Bytes = redis.Bytes
var Float64 = redis.Float64
var Int = redis.Int
var Int64 = redis.Int64
var Int64Map = redis.Int64Map
var IntMap = redis.IntMap
var Ints = redis.Ints
var MultiBulk = redis.MultiBulk
var Scan = redis.Scan
var ScanSlice = redis.ScanSlice
var ScanStruct = redis.ScanStruct
var String = redis.String
var Strings = redis.Strings
var Uint64 = redis.Uint64
var Values = redis.Values

type Args struct{ redis.Args }
type Error struct{ redis.Error }
type Message struct{ redis.Message }
type PMessage struct{ redis.PMessage }
type Pong struct{ redis.Pong }
type PubSubConn struct{ redis.PubSubConn }
type Script struct{ redis.Script }

func NewScript(keyCount int, src string) *Script {
s := redis.NewScript(keyCount, src)
return &Script{Script: *s}
}

type Subscription struct{ redis.Subscription }