GoFusionCache

package module
v0.0.2-0...-0283038 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMemoryNotFound = errors.New("memory not found")
	ErrRedisNotFound  = errors.New("redis not found")
)

Functions

This section is empty.

Types

type Cache

type Cache[K comparable, V any] interface {
	GetItem(context.Context, K) (V, error)
	SetItem(context.Context, K, V) error
	DelItem(context.Context, K) error
}

type DefaultMemoryCacheImpl

type DefaultMemoryCacheImpl[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func (DefaultMemoryCacheImpl[K, V]) DelItem

func (d DefaultMemoryCacheImpl[K, V]) DelItem(c context.Context, k string) error

func (DefaultMemoryCacheImpl[K, V]) GetItem

func (d DefaultMemoryCacheImpl[K, V]) GetItem(c context.Context, k string) (string, error)

func (DefaultMemoryCacheImpl[K, V]) SetItem

func (d DefaultMemoryCacheImpl[K, V]) SetItem(c context.Context, k, v string) error

type DefaultRedisCacheImpl

type DefaultRedisCacheImpl[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func (DefaultRedisCacheImpl[K, V]) DelItem

func (d DefaultRedisCacheImpl[K, V]) DelItem(c context.Context, k string) error

func (DefaultRedisCacheImpl[K, V]) GetItem

func (d DefaultRedisCacheImpl[K, V]) GetItem(c context.Context, k string) (string, error)

func (DefaultRedisCacheImpl[K, V]) SetItem

func (d DefaultRedisCacheImpl[K, V]) SetItem(c context.Context, k, v string) error

type FusionCache

type FusionCache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func New

func New[K comparable, V any](mc MemoryCache[K, V], rc RedisCache[K, V]) *FusionCache[K, V]

func NewDefaultFusionCache

func NewDefaultFusionCache(dsn string, defaultExpiration, cleanupInterval time.Duration) *FusionCache[string, string]

func (*FusionCache[K, V]) Del

func (fc *FusionCache[K, V]) Del(c context.Context, k K) error

func (*FusionCache[K, V]) Get

func (fc *FusionCache[K, V]) Get(c context.Context, k K, loaders ...Loader[K, V]) (V, error)

func (*FusionCache[K, V]) Set

func (fc *FusionCache[K, V]) Set(c context.Context, k K, v V) error

type Loader

type Loader[K comparable, V any] func(K) (V, error)

type MemoryCache

type MemoryCache[K comparable, V any] interface {
	Cache[K, V]
}

func NewDefaultMemoryCache

func NewDefaultMemoryCache(defaultExpiration, cleanupInterval time.Duration) MemoryCache[string, string]

type RedisCache

type RedisCache[K comparable, V any] interface {
	Cache[K, V]
}

func NewDefaultRedisCache

func NewDefaultRedisCache(dsn string) RedisCache[string, string]

func NewDefaultRedisCacheV2

func NewDefaultRedisCacheV2(cli *redis.Client) RedisCache[string, string]

Jump to

Keyboard shortcuts

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