rediscache

package
v0.64.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const Type = "redis"

Type is redis type identifier.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is Redis cache implementation.

func New

func New(cfg Config, logger log.Logger) *Cache

New creates and returns an initialized Redis Cache instance.

func (*Cache) Del

func (c *Cache) Del(ctx context.Context, ns string, keys ...string) error

Del satisfies Cache interface.

func (*Cache) DelNS

func (c *Cache) DelNS(ctx context.Context, ns string) error

DelNS removes all keys contained under a given namespace from the cache store.

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, ns, key string) ([]byte, error)

Get satisfies Cache interface.

func (*Cache) HasKey

func (c *Cache) HasKey(ctx context.Context, ns, key string) (bool, error)

HasKey satisfies Cache interface.

func (*Cache) Put

func (c *Cache) Put(ctx context.Context, ns, key string, val []byte) error

Put satisfies Cache interface.

func (*Cache) Start

func (c *Cache) Start(ctx context.Context) error

Start satisfies Cache interface.

func (*Cache) Stop

func (c *Cache) Stop(ctx context.Context) error

Stop satisfies Cache interface.

func (*Cache) Type

func (c *Cache) Type() string

Type satisfies Cache interface.

type Config

type Config struct {
	SRV          string        `fig:"srv"`
	Addresses    []string      `fig:"addresses"`
	Username     string        `fig:"username"`
	Password     string        `fig:"password"`
	DB           int           `fig:"db"`
	DialTimeout  time.Duration `fig:"dial_timeout" default:"3s"`
	ReadTimeout  time.Duration `fig:"read_timeout" default:"5s"`
	WriteTimeout time.Duration `fig:"write_timeout" default:"5s"`
	TTL          time.Duration `fig:"ttl" default:"24h"`
}

Config contains Redis cache configuration.

Jump to

Keyboard shortcuts

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