Documentation
¶
Overview ¶
Package redis is a simple redis cache implement. base on the package: https://github.com/gomodule/redigo
Example ¶
package main
import (
"fmt"
"github.com/gookit/cache/redis"
)
func main() {
// init driver
c := redis.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)
}
Index ¶
- Constants
- type Redigo
- func (c *Redigo) Clear() error
- func (c *Redigo) Close() error
- func (c *Redigo) Connect() *Redigo
- func (c *Redigo) Del(key string) (err error)
- func (c *Redigo) DelMulti(keys []string) (err error)
- func (c *Redigo) Get(key string) any
- func (c *Redigo) GetAs(key string, ptr any) error
- func (c *Redigo) GetMulti(keys []string) map[string]any
- func (c *Redigo) Has(key string) bool
- func (c *Redigo) Pool() *redis.Pool
- func (c *Redigo) Set(key string, val any, ttl time.Duration) (err error)
- func (c *Redigo) SetMulti(values map[string]any, ttl time.Duration) (err error)
- func (c *Redigo) String() string
- type RedisCache
Examples ¶
Constants ¶
View Source
const Name = "redigo"
Name driver name
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Redigo ¶ added in v0.2.0
type Redigo struct {
cache.BaseDriver
// contains filtered or unexported fields
}
Redigo driver definition. redigo doc link: https://pkg.go.dev/github.com/gomodule/redigo/redis#pkg-examples
Click to show internal directories.
Click to hide internal directories.