redis

package
v0.0.0-...-ec03ccd Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 11 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) 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

func (*Cache) Scan

func (c *Cache) Scan(ctx context.Context, match string) (cache.Iterator, error)

Scan scans the keys matched by match string

type ScanIterator

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

ScanIterator is a wrapper for redis ScanIterator

func (*ScanIterator) Next

func (i *ScanIterator) Next(ctx context.Context) bool

Next check whether has the next element

func (*ScanIterator) Val

func (i *ScanIterator) Val() string

Val returns the key

Jump to

Keyboard shortcuts

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