Documentation
¶
Overview ¶
Package redis implements a redis adapter for github.com/hamba/pkg/cache.
Index ¶
- type OptsFunc
- type Redis
- func (c Redis) Add(key string, value interface{}, expire time.Duration) error
- func (c Redis) Dec(key string, value uint64) (int64, error)
- func (c Redis) Delete(key string) error
- func (c Redis) Get(key string) cache.Item
- func (c Redis) GetMulti(keys ...string) ([]cache.Item, error)
- func (c Redis) Inc(key string, value uint64) (int64, error)
- func (c Redis) Replace(key string, value interface{}, expire time.Duration) error
- func (c Redis) Set(key string, value interface{}, expire time.Duration) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OptsFunc ¶
type OptsFunc func(*redis.Options)
OptsFunc represents an configuration function for Redis.
func WithPoolSize ¶
WithPoolSize configures the Redis pool size.
func WithPoolTimeout ¶
WithPoolTimeout configures the Redis pool timeout.
func WithReadTimeout ¶
WithReadTimeout configures the Redis read timeout.
func WithWriteTimeout ¶
WithWriteTimeout configures the Redis write timeout.
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
Redis is a redis adapter.
func New ¶
New create a new Redis instance.
Example ¶
package main import ( "time" "github.com/hamba/cache/redis" ) func main() { c, err := redis.New("redis://localhost:6379", redis.WithReadTimeout(10*time.Millisecond)) if err != nil { // Handle error } i := c.Get("foobar") if i.Err != nil { // Handle error } _, _ = i.Float64() }
Click to show internal directories.
Click to hide internal directories.