Documentation ¶
Overview ¶
Package goredis is a simple redis cache implement. base on the package: github.com/go-redis/redis
Example ¶
package main import ( "fmt" "github.com/gookit/cache/goredis" ) func main() { // init driver c := goredis.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 ¶
- Constants
- Variables
- type GoRedis
- func (c *GoRedis) Clear() error
- func (c *GoRedis) Close() error
- func (c *GoRedis) Connect() *GoRedis
- func (c *GoRedis) Del(key string) error
- func (c *GoRedis) DelMulti(keys []string) error
- func (c *GoRedis) Get(key string) interface{}
- func (c *GoRedis) GetAs(key string, ptr interface{}) error
- func (c *GoRedis) GetMulti(keys []string) map[string]interface{}
- func (c *GoRedis) Has(key string) bool
- func (c *GoRedis) Set(key string, val interface{}, ttl time.Duration) (err error)
- func (c *GoRedis) SetMulti(values map[string]interface{}, ttl time.Duration) (err error)
- func (c *GoRedis) String() string
- func (c *GoRedis) WithContext(ctx context.Context) gsr.ContextCacher
Examples ¶
Constants ¶
View Source
const Name = "goredis"
Name driver name
Variables ¶
View Source
var CtxForExec = context.Background()
CtxForExec default ctx for exec command
Functions ¶
This section is empty.
Types ¶
type GoRedis ¶
type GoRedis struct { cache.BaseDriver // contains filtered or unexported fields }
GoRedis struct
func (*GoRedis) WithContext ¶ added in v0.3.1
func (c *GoRedis) WithContext(ctx context.Context) gsr.ContextCacher
WithContext for operate
Click to show internal directories.
Click to hide internal directories.