Documentation
¶
Overview ¶
Package redis provides a Redis-backed implementation of cache.Cache.
Index ¶
- type Cache
- func (c *Cache) Clear(ctx context.Context) error
- func (c *Cache) Client() goredis.Cmdable
- func (c *Cache) Close() error
- func (c *Cache) Delete(ctx context.Context, key string) error
- func (c *Cache) Exists(ctx context.Context, key string) (bool, error)
- func (c *Cache) Get(ctx context.Context, key string) ([]byte, error)
- func (c *Cache) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache wraps a Redis client and implements cache.Cache.
func NewWithClient ¶
NewWithClient wraps an existing go-redis Cmdable (Client, ClusterClient, etc.). If the client implements Close(), it will be called by Cache.Close.
func (*Cache) Clear ¶
Clear removes keys matching the configured prefix. Without a prefix it runs FLUSHDB (use with care).
type Option ¶
type Option func(*config)
Option configures a Redis cache.
func WithDefaultTTL ¶
WithDefaultTTL sets the default TTL used when Set is called with ttl == 0.
Click to show internal directories.
Click to hide internal directories.