Documentation ¶
Index ¶
- type RedisCallers
- func (c *RedisCallers) Del(keys ...string) error
- func (c *RedisCallers) Get(k string) (v string, err error)
- func (c *RedisCallers) SearchByKeys(patten string, keywords []string) (objs []RedisObj, err error)
- func (c *RedisCallers) SearchByScan(patten string, keywords []string, count int64) (objs []RedisObj, err error)
- func (c *RedisCallers) Set(k, v string, exp time.Duration) (newVal string, err error)
- func (c *RedisCallers) SetInBatch(objs []RedisObj) (err error)
- type RedisError
- type RedisObj
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RedisCallers ¶
RedisCallers represent a client that connects to our redis DB.
func NewCaller ¶
func NewCaller(config *viper.Viper) *RedisCallers
func NewCallerSentinel ¶
func NewCallerSentinel(config *viper.Viper) *RedisCallers
NewCaller initialises a new connection client to the redis DB.
func (*RedisCallers) Del ¶
func (c *RedisCallers) Del(keys ...string) error
Del deletes entries by their keys
func (*RedisCallers) Get ¶
func (c *RedisCallers) Get(k string) (v string, err error)
Get gets an entry by its key.
func (*RedisCallers) SearchByKeys ¶
func (c *RedisCallers) SearchByKeys(patten string, keywords []string) (objs []RedisObj, err error)
* Using scan when keySpace is small
func (*RedisCallers) SearchByScan ¶
func (c *RedisCallers) SearchByScan(patten string, keywords []string, count int64) (objs []RedisObj, err error)
Search returns any entries that fulfills the given search patten and keywords. Pattern is used to check the key while keywords are used to check the values of the matched keys. For example, assume we have {'user:1', 'aaa'}, {'user:2', 'abc'}, {'user:3', 'bbb'} three entries, if the given pattern is 'user:*' and the keywords is ['a'], the returned entries are: {'user:1', 'aaa'}, {'user:2', 'abc'}. * Using scan when keySpace is big
func (*RedisCallers) Set ¶
Set creates a new entry or updates an existed entry with a specified lifetime, the default lifetime is zero.
func (*RedisCallers) SetInBatch ¶
func (c *RedisCallers) SetInBatch(objs []RedisObj) (err error)
SetInBatch creates multiple new entries or updates multiple existed entries given by a slice of RedisObj
type RedisError ¶
A RedisError represents a structured redis error.
func (*RedisError) Error ¶
func (e *RedisError) Error() string
Error returns a formatted redis error message.