cache

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCacheMissErr added in v1.0.5

func IsCacheMissErr(err error) bool

func NewMemCache

func NewMemCache() *cache.Cache[[]byte]

func NewRedisCache

func NewRedisCache(rc redis.Client, ttl time.Duration) *cache.Cache[[]byte]

Types

type Cache

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

func New

func New[V any](c *cache.Cache[[]byte]) *Cache[V]

func (*Cache[T]) Clear

func (c *Cache[T]) Clear(ctx context.Context) error

func (*Cache[T]) Delete

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

func (*Cache[T]) Get

func (c *Cache[T]) Get(ctx context.Context, key string) (*T, error)

func (*Cache[T]) Set

func (c *Cache[T]) Set(ctx context.Context, key string, val T) error

type GenericCache added in v1.0.5

type GenericCache struct {
	// contains filtered or unexported fields
}

func NewGenericCache added in v1.0.5

func NewGenericCache(cacheKey string, c *cache.Cache[[]byte]) *GenericCache

func (*GenericCache) Clear added in v1.0.5

func (c *GenericCache) Clear(ctx context.Context) error

func (*GenericCache) Delete added in v1.0.5

func (c *GenericCache) Delete(ctx context.Context, key string) error

func (*GenericCache) Get added in v1.0.5

func (c *GenericCache) Get(ctx context.Context, key string, target any) error

func (*GenericCache) Set added in v1.0.5

func (c *GenericCache) Set(ctx context.Context, key string, val any) error

type MultiKeyCache

type MultiKeyCache[V MultiKeyObject] struct {
	// contains filtered or unexported fields
}

func NewMultiKeyCache

func NewMultiKeyCache[V MultiKeyObject](c cache.Cache[V]) *MultiKeyCache[V]

func (*MultiKeyCache[V]) Delete

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

func (*MultiKeyCache[V]) Get

func (m *MultiKeyCache[V]) Get(ctx context.Context, key string) (V, error)

func (*MultiKeyCache[V]) Set

func (m *MultiKeyCache[V]) Set(ctx context.Context, value V) error

type MultiKeyObject

type MultiKeyObject interface {
	GetKeys() []string
}

type RedisOptions

type RedisOptions struct {
	Username string
	Password string
	Addr     string
	DB       int
	TLS      *TLS
}

func (*RedisOptions) GetGoRedisOptions

func (o *RedisOptions) GetGoRedisOptions() *goredis.Options

type TLS

type TLS struct {
	KeyPath  string
	CertPath string
	CaPath   string
}

func (*TLS) GetTLSConfig

func (t *TLS) GetTLSConfig() (*tls.Config, error)

Jump to

Keyboard shortcuts

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