redis

package
Version: v0.0.0-...-0feb2aa Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts cache.Options) (cache.Cache, error)

New returns redis cache

func ParseSentinelURL

func ParseSentinelURL(redisURL string) (*redis.FailoverOptions, error)

ParseSentinelURL parses sentinel url to redis FailoverOptions. It's a modified version of go-redis ParseURL(https://github.com/go-redis/redis/blob/997118894af9d4244d4a471f2b317eead9c9ca62/options.go#L222) because official version does not support parse sentinel mode.

Types

type Cache

type Cache struct {
	*redis.Client
	// contains filtered or unexported fields
}

Cache redis cache

func (*Cache) Contains

func (c *Cache) Contains(ctx context.Context, key string) bool

Contains returns true if key exists

func (*Cache) Delete

func (c *Cache) Delete(ctx context.Context, key string) error

Delete delete item from cache by key

func (*Cache) Fetch

func (c *Cache) Fetch(ctx context.Context, key string, value interface{}) error

Fetch retrieve the cached key value

func (*Cache) Keys

func (c *Cache) Keys(ctx context.Context, prefixes ...string) ([]string, error)

Keys returns the key matched by prefixes.

func (*Cache) Ping

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

Ping ping the cache

func (*Cache) Save

func (c *Cache) Save(ctx context.Context, key string, value interface{}, expiration ...time.Duration) error

Save cache the value by key

Source Files

Jump to

Keyboard shortcuts

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