Documentation ¶
Overview ¶
Package radixs is used for retrieving redis connections, and has helper methods for interacting with the data held within redis. Use this package with https://github.com/mediocregopher/radix.v2
Index ¶
Constants ¶
const DefaultTimeout = 30 * time.Second
DefaultTimeout is used when reading from socket
Variables ¶
var Debug bool
Debug If true turns on debug logging and agg support (see https://github.com/grooveshark/golib)
Functions ¶
func BuildAllInfoMap ¶
BuildAllInfoMap will call `INFO ALL` and return a mapping of map[string]string for each section in the output
func BuildMapFromInfoString ¶
BuildMapFromInfoString will take the string from a Redis info call and return a map[string]string
Types ¶
type Client ¶
type Client struct { // Timeout to use for reads/writes to redis. This defaults to DefaultTimeout, // but can be overwritten immediately after NewClient is called Timeout time.Duration // contains filtered or unexported fields }
Client is a client for the redis. It can talk to a pool of redis instances and failover from one to the other if one loses connectivity
type Config ¶
type Config struct { // RedisAddr Address redis is listening on RedisAddr string `json:"redis_addr"` // RedisSentinels A sentinel address to connect to through to the client - overrides other options RedisSentinels []string `json:"redis_sentinel_addr"` // RedisSentinelGroup A redis sentinel group name for selecting which redis masters to connect RedisSentinelGroup string `json:"redis_sentinel_group"` // RedisCluster Whether or not to treat the redis address as a node in a larger cluster RedisCluster bool `json:"redis_cluster"` // RedisSentinel Whether or not to redis sentinel mode RedisSentinel bool `json:"redis_sentinel"` }
Config contains DB configs
type DBer ¶
type DBer interface { // Cmd is a function which will perform the given cmd/args in redis and // returns the resp. It automatically handles using redis cluster, if that // is enabled Cmd(string, ...interface{}) *redis.Resp // Pipe runs a set of commands (given by p) one after the other. It is *not* // guaranteed that all the commands will be run on the same client. If any // commands return an error the pipeline will stop and return that error. // Otherwise the Resp from each command is returned in a slice // // r, err := db.Pipe( // db.PP("SET", "foo", "bar"), // db.PP("GET", "foo"), // ) Pipe(...*PipePart) ([]*redis.Resp, error) // Scan is a function which returns a channel to which keys matching the // given pattern are written to. The channel must be read from until it is // closed, which occurs when there are no more keys or when an error has // occurred (this error will be logged) // // This should not be used in any critical paths Scan(string) <-chan string // GetAddr returns any valid address of a redis instance. Useful for cases // where we want to create redis connections external to this db package GetAddr() (string, error) }
DBer is implemented and used by the application to interact with whatever backend has been chosen