Documentation ¶
Overview ¶
Package redis is a simple redis cache implement. base on the package: github.com/gomodule/redigo
Example ¶
// init driver c := Connect("127.0.0.1:6379", "", 0) // set _ = c.Set("name", "cache value", 60) // get val := c.Get("name") // del _ = c.Del("name") // get: "cache value" fmt.Print(val)
Output:
Index ¶
- type RedisCache
- func (c *RedisCache) Clear() error
- func (c *RedisCache) Close() error
- func (c *RedisCache) Connect() *RedisCache
- func (c *RedisCache) Del(key string) (err error)
- func (c *RedisCache) DelMulti(keys []string) (err error)
- func (c *RedisCache) Get(key string) interface{}
- func (c *RedisCache) GetMulti(keys []string) map[string]interface{}
- func (c *RedisCache) Has(key string) bool
- func (c *RedisCache) Key(key string) string
- func (c *RedisCache) LastErr() error
- func (c *RedisCache) Pool() *redis.Pool
- func (c *RedisCache) Set(key string, val interface{}, ttl time.Duration) (err error)
- func (c *RedisCache) SetMulti(values map[string]interface{}, ttl time.Duration) (err error)
- func (c *RedisCache) String() string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RedisCache ¶
type RedisCache struct { Debug bool // key prefix Prefix string Logger *log.Logger // contains filtered or unexported fields }
RedisCache definition. redigo doc link: https://godoc.org/github.com/gomodule/redigo/redis
func Connect ¶
func Connect(url, pwd string, dbNum int) *RedisCache
Connect create and connect to redis server
func (*RedisCache) DelMulti ¶
func (c *RedisCache) DelMulti(keys []string) (err error)
DelMulti values by keys
func (*RedisCache) GetMulti ¶
func (c *RedisCache) GetMulti(keys []string) map[string]interface{}
GetMulti values by keys
func (*RedisCache) Set ¶
func (c *RedisCache) Set(key string, val interface{}, ttl time.Duration) (err error)
Set value by key
Click to show internal directories.
Click to hide internal directories.