rediscache

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2025 License: Apache-2.0 Imports: 11 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

cachestore-redis

cachestore backend via Redis.

See also:

LICENSE

Copyright (c) 2021-present Sequence Platforms Inc.

Licensed under Apache-2.0

Documentation

Index

Constants

View Source
const DefaultTTL = time.Second * 24 * 60 * 60 // 1 day in seconds

Variables

This section is empty.

Functions

func NewBackend

func NewBackend(cfg *Config, opts ...cachestore.StoreOptions) (cachestore.Backend, error)

Types

type Config

type Config struct {
	cachestore.StoreOptions
	Enabled   bool          `toml:"enabled"`
	Host      string        `toml:"host"`
	Port      uint16        `toml:"port"`
	DBIndex   int           `toml:"db_index"`   // default 0
	MaxIdle   int           `toml:"max_idle"`   // default 4
	MaxActive int           `toml:"max_active"` // default 8
	KeyTTL    time.Duration `toml:"key_ttl"`    // default 1 day
}

type RedisStore

type RedisStore[V any] struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache[V any](cfg *Config, opts ...cachestore.StoreOptions) (*RedisStore[V], error)

func (*RedisStore[V]) BatchGet

func (c *RedisStore[V]) BatchGet(ctx context.Context, keys []string) ([]V, []bool, error)

func (*RedisStore[V]) BatchSet

func (c *RedisStore[V]) BatchSet(ctx context.Context, keys []string, values []V) error

func (*RedisStore[V]) BatchSetEx

func (c *RedisStore[V]) BatchSetEx(ctx context.Context, keys []string, values []V, ttl time.Duration) error

func (*RedisStore[V]) ByteStore

func (c *RedisStore[V]) ByteStore() cachestore.Store[[]byte]

func (*RedisStore[V]) ClearAll

func (c *RedisStore[V]) ClearAll(ctx context.Context) error

func (*RedisStore[V]) Delete

func (c *RedisStore[V]) Delete(ctx context.Context, key string) error

func (*RedisStore[V]) DeletePrefix

func (c *RedisStore[V]) DeletePrefix(ctx context.Context, keyPrefix string) error

func (*RedisStore[V]) Exists

func (c *RedisStore[V]) Exists(ctx context.Context, key string) (bool, error)

func (*RedisStore[V]) Get

func (c *RedisStore[V]) Get(ctx context.Context, key string) (V, bool, error)

func (*RedisStore[V]) GetOrSetWithLock

func (c *RedisStore[V]) GetOrSetWithLock(
	ctx context.Context, key string, getter func(context.Context, string) (V, error),
) (V, error)

func (*RedisStore[V]) GetOrSetWithLockEx

func (c *RedisStore[V]) GetOrSetWithLockEx(
	ctx context.Context, key string, getter func(context.Context, string) (V, error), ttl time.Duration,
) (V, error)

func (*RedisStore[V]) Name

func (c *RedisStore[V]) Name() string

func (*RedisStore[V]) Options

func (c *RedisStore[V]) Options() cachestore.StoreOptions

func (*RedisStore[V]) RedisClient

func (c *RedisStore[V]) RedisClient() *redis.Client

func (*RedisStore[V]) Set

func (c *RedisStore[V]) Set(ctx context.Context, key string, value V) error

func (*RedisStore[V]) SetEx

func (c *RedisStore[V]) SetEx(ctx context.Context, key string, value V, ttl time.Duration) error

Directories

Path Synopsis
_examples
basic command

Jump to

Keyboard shortcuts

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