Documentation
¶
Index ¶
- type Client
- func (c *Client) Close() error
- func (c *Client) Do(cmd, key string, rest ...interface{}) (interface{}, error)
- func (c *Client) GetConn() redis.Conn
- func (c *Client) GetObject(origin, key string, o interface{}) error
- func (c *Client) GetPool() *redis.Pool
- func (c *Client) GetSettings(origin string, s interface{}) error
- func (c *Client) IsErrNil(err error) bool
- func (c *Client) Prefix(key string) string
- func (c *Client) SaveObject(origin, key string, o interface{}) error
- func (c *Client) SaveSettings(origin string, s interface{}) error
- func (c *Client) WithOrigin(origin, key string) string
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Name is the identifier of worker using this library. This is used to // prefix keys along with Version in Redis. Name string Version string // Seperator is a string that seperates Name, Version and the key. Seperator string // contains filtered or unexported fields }
Client is a client for this library. Use New() to initalize it.
func (*Client) Do ¶
Do is the primary method for interacting with Redis. It runs the given cmd in a redis conn from the pool and closes it when done.
It also prefixes all keys with name and version passed in Config when initializing.
func (*Client) GetConn ¶
GetConn returns a single redigo Redis connection. Be sure to close the connection when finished.
func (*Client) GetObject ¶
GetObject gets marshalled object for origin and key. key: <worker>:<version>:<origin>:<key>
func (*Client) GetSettings ¶
GetSettings gets settings for origin. key: <worker>:<version>:<origin>:settings
func (*Client) Prefix ¶
Prefix prefixes given key with name and version passed in Config when initializing.
func (*Client) SaveObject ¶
SaveObject saves object as json string for origin and key. It uses string instead of bytes for ease of debugging.
key: <worker>:<version>:<origin>:<key>
func (*Client) SaveSettings ¶
SaveSettings saves given settings for origin. key: <worker>:<version>:<origin>:settings
func (*Client) WithOrigin ¶
WithOrigin prefixes origin to key to indicate key belongs to that origin.
type Config ¶
type Config struct { // Name is identifier of app using this library. This is used as prefix in // keys. Name string // Version is version of app using this library. This is used as prefix in // keys. Version string // MaxIdle is redigo/redis setting. MaxIdle int // MaxActive is redigo/redis setting. MaxActive int // IdleTimeout is redigo/redis setting. IdleTimeout time.Duration }
Config is the user definable options.
func NewDefaultConfig ¶
NewDefaultConfig returns *Config with sane defaults for redigo/redis.