-
Notifications
You must be signed in to change notification settings - Fork 1.2k
FAQ
See https://godoc.org/github.com/gomodule/redigo/redis#hdr-Concurrency.
The args parameter to the connection Send and Do methods is variadic. Use the ... notation to pass a slice to a variadic argument.
// Set fields in HASH "myhash" using values from map fvs.
var args = []interface{}{"myhash"}
for f, v := range fvs {
args = append(args, f, v)
}
_, err := conn.Do("HMSET", args...)
If you have a slice that's not of type []interface{}, then copy the values to a []interface{} before calling the Send or Do method.
Redigo's Args type can be used to construct variable length argument lists.
Some Redis command names contain a space. Split the name on space. Pass the first part as the command name and the remaining parts as arguments:
_, err := conn.Do("CONFIG", "SET", "loglevel", "warning")
No. The application can easily serialize structs using encoding/gob, encoding/json or other packages.
The Args AddFlat method and the ScanStruct function are provided to simplify code for building command argument lists and parsing command responses. These functions are not intended to be used as a tool for serializing structs to Redis.
No, but the application can use Vitess pools with Redigo. See Vitess-Example for a brief example of how to use a Vitess pool with Redigo.