cachex

package
v10.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BadgerConfig

type BadgerConfig struct {
	Path string
}

type Cacher

type Cacher interface {
	Set(ctx context.Context, ns, key, value string, expiration ...time.Duration) error
	Get(ctx context.Context, ns, key string) (string, bool, error)
	GetAndDelete(ctx context.Context, ns, key string) (string, bool, error)
	Exists(ctx context.Context, ns, key string) (bool, error)
	Delete(ctx context.Context, ns, key string) error
	Iterator(ctx context.Context, ns string, fn func(ctx context.Context, key, value string) bool) error
	Close(ctx context.Context) error
}

Cacher is the interface that wraps the basic Get, Set, and Delete methods.

func NewBadgerCache

func NewBadgerCache(cfg BadgerConfig, opts ...Option) Cacher

Create badger-based cache

func NewMemoryCache

func NewMemoryCache(cfg MemoryConfig, opts ...Option) Cacher

func NewRedisCache

func NewRedisCache(cfg RedisConfig, opts ...Option) Cacher

Create redis-based cache

func NewRedisCacheWithClient

func NewRedisCacheWithClient(cli *redis.Client, opts ...Option) Cacher

Use redis client create cache

func NewRedisCacheWithClusterClient

func NewRedisCacheWithClusterClient(cli *redis.ClusterClient, opts ...Option) Cacher

Use redis cluster client create cache

type MemoryConfig

type MemoryConfig struct {
	CleanupInterval time.Duration
}

type Option

type Option func(*options)

func WithDelimiter

func WithDelimiter(delimiter string) Option

type RedisConfig

type RedisConfig struct {
	Addr     string
	Username string
	Password string
	DB       int
}

Jump to

Keyboard shortcuts

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