Documentation ¶
Overview ¶
Package util is a collection of helper functions for interacting with various parts of the radix.v2 package
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LuaEval ¶
LuaEval calls EVAL on the given Cmder for the given script, passing the key count and argument list in as well. See http://redis.io/commands/eval for more on how EVAL works and for the meaning of the keys argument.
LuaEval will automatically try to call EVALSHA first in order to preserve bandwidth, and only falls back on EVAL if the script has never been used before.
This method works with any of the Cmder's implemented in radix.v2, including Client, Pool, and Cluster.
r := util.LuaEval(c, `return redis.call('GET', KEYS[1])`, 1, "foo")
func Scan ¶
Scan is a helper function for performing any of the redis *SCAN functions. It takes in a channel which keys returned by redis will be written to, and returns an error should any occur. The input channel will always be closed when Scan returns, and *must* be read until it is closed.
The key argument is only needed if cmd isn't SCAN
Example SCAN command
ch := make(chan string) var err error go func() { err = util.Scan(r, ch, "SCAN", "", "*") }() for key := range ch { // do something with key } if err != nil { // handle error }
Example HSCAN command
ch := make(chan string) var err error go func() { err = util.Scan(r, ch, "HSCAN", "somekey", "*") }() for key := range ch { // do something with key } if err != nil { // handle error }
Types ¶
type Cmder ¶
Cmder is an interface which can be used to interchangeably work with either redis.Client (the basic, single connection redis client), pool.Pool, or cluster.Cluster. All three implement a Cmd method (although, as is the case with Cluster, sometimes with different limitations), and therefore all three are Cmders