redis

package
v0.55.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package redis is the concrete implementation of the cache abstraction.

Index

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 encapsulates a Redis-based caching mechanism, driven by go-redis/redis/v7.

func New

func New(ctx context.Context, opt Options) (*Cache, error)

New returns a new Redis client that will be used as the cache store.

func (*Cache) Get

func (c *Cache) Get(key string) (interface{}, bool, error)

Get executes a lookup and returns whether a key exists in the cache along with its value.

func (*Cache) Purge

func (c *Cache) Purge() error

Purge evicts all keys present in the cache.

func (*Cache) Remove

func (c *Cache) Remove(key string) error

Remove evicts a specific key from the cache.

func (*Cache) Set

func (c *Cache) Set(key string, value interface{}) error

Set registers a key-value pair to the cache.

func (*Cache) SetTTL

func (c *Cache) SetTTL(key string, value interface{}, ttl time.Duration) error

SetTTL registers a key-value pair to the cache, specifying an expiry time.

type Options

type Options redis.Options

Options exposes the options struct from go-redis package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL