redis_cache

package
v4.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KV added in v4.3.1

type KV struct {
	Key            string
	V              []byte
	StoreTime      time.Time
	ExpirationTime time.Time
}

type RedisCache

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

func NewRedisCache added in v4.3.1

func NewRedisCache(opts RedisCacheOpts) (*RedisCache, error)

func (*RedisCache) BatchStore added in v4.3.1

func (r *RedisCache) BatchStore(b []KV)

BatchStore stores a batch of kv into redis via redis pipeline.

func (*RedisCache) Close

func (r *RedisCache) Close() error

Close closes the redis client.

func (*RedisCache) Get

func (r *RedisCache) Get(key string) (v []byte, storedTime, expirationTime time.Time)

func (*RedisCache) Len

func (r *RedisCache) Len() int

func (*RedisCache) Store

func (r *RedisCache) Store(key string, v []byte, storedTime, expirationTime time.Time)

Store stores kv into redis.

type RedisCacheOpts added in v4.3.1

type RedisCacheOpts struct {
	// Client cannot be nil.
	Client redis.Cmdable

	// ClientCloser closes Client when RedisCache.Close is called.
	// Optional.
	ClientCloser io.Closer

	// ClientTimeout specifies the timeout for read and write operations.
	// Default is 50ms.
	ClientTimeout time.Duration

	// Logger is the *zap.Logger for this RedisCache.
	// A nil Logger will disable logging.
	Logger *zap.Logger
}

func (*RedisCacheOpts) Init added in v4.3.1

func (opts *RedisCacheOpts) Init() error

Jump to

Keyboard shortcuts

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