cache

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTimeout time.Duration = 30 * time.Minute

Functions

func NewRedisClient added in v0.9.0

func NewRedisClient(logger *zap.Logger) *redis.Client

Types

type Cache

type Cache[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any]() *Cache[T]

func NewWithTimeout added in v0.6.3

func NewWithTimeout[T any](dur time.Duration) *Cache[T]

func (*Cache[T]) Get

func (ct *Cache[T]) Get(key string) (T, bool)

func (*Cache[T]) Set

func (ct *Cache[T]) Set(key string, value T)

type CacheProvider added in v0.8.2

type CacheProvider[T any] interface {
	Set(key string, value T)
	Get(key string) (T, bool)
}

func NewCacheProvider added in v0.8.2

func NewCacheProvider[T any](t time.Duration) CacheProvider[T]

type CachedList added in v0.9.1

type CachedList[T any] interface {
	Append(ctx context.Context, key string, raw ...T) error
	GetAll(ctx context.Context, key string) ([]T, error)
	Del(ctx context.Context, key string) error
}

func NewCachedList added in v0.9.1

func NewCachedList[T any](prefix string, dur time.Duration) CachedList[T]

type CachedListRedis added in v0.9.1

type CachedListRedis[T any] struct {
	Logger  *zap.Logger
	Client  *redis.Client
	Prefix  string
	Timeout time.Duration
}

func (*CachedListRedis[T]) Append added in v0.9.1

func (ll *CachedListRedis[T]) Append(ctx context.Context, key string, raw ...T) error

func (*CachedListRedis[T]) Del added in v0.9.1

func (ll *CachedListRedis[T]) Del(ctx context.Context, key string) error

func (*CachedListRedis[T]) GetAll added in v0.9.1

func (ll *CachedListRedis[T]) GetAll(ctx context.Context, key string) ([]T, error)

type RedisConfig added in v0.9.0

type RedisConfig struct {
	Host    string
	Port    uint
	Account string
	Passwd  string
	Caroot  string // where is the ca pem file.
	Tls     bool   //TLS enabled ?
	DB      int    // 0: dev, 1: uat, 3: prd
}

type RedisProvider added in v0.9.0

type RedisProvider[T any] struct {
	// contains filtered or unexported fields
}

func (*RedisProvider[T]) Get added in v0.9.0

func (r *RedisProvider[T]) Get(key string) (T, bool)

Get implements CacheProvider.

func (*RedisProvider[T]) Set added in v0.9.0

func (r *RedisProvider[T]) Set(key string, value T)

Set implements CacheProvider.

type WithKey added in v0.9.1

type WithKey interface {
	Key() string
}

Jump to

Keyboard shortcuts

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