cachex

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MIT Imports: 9 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 Cache

type Cache 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
}

func InitCache

func InitCache(ctx context.Context) (Cache, func(), error)

func NewBadgerCache

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

func NewMemoryCache

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

func NewRedisCache

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

func NewRedisCacheWithClient

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

func NewRedisCacheWithClusterClient

func NewRedisCacheWithClusterClient(cli *redis.ClusterClient, opts ...Option) 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