cache

package
v0.0.0-...-550ecfb Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: AGPL-3.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 Cache

type Cache interface {
	Get(ctx context.Context, key string, value any) error
	Set(ctx context.Context, key string, value any, ttl time.Duration) error
	Update(ctx context.Context, key string, value any) error
	Delete(ctx context.Context, key string) error
}

Cache defines a generic interface for cache operations. Implementations can use any underlying storage (Redis, in-memory, etc.)

type CacheableObject

type CacheableObject[T any] interface {
	CacheKey() string
	AdditionalCacheKeys() []string
	TTL() time.Duration
}

type RedisCacheAdapter

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

RedisCacheAdapter implements the Cache interface using Redis.

func NewRedisCacheAdapter

func NewRedisCacheAdapter(client *redis.Client) *RedisCacheAdapter

func (*RedisCacheAdapter) Delete

func (r *RedisCacheAdapter) Delete(ctx context.Context, key string) error

func (*RedisCacheAdapter) Get

func (r *RedisCacheAdapter) Get(ctx context.Context, key string, value any) error

func (*RedisCacheAdapter) Set

func (r *RedisCacheAdapter) Set(ctx context.Context, key string, value any, ttl time.Duration) error

func (*RedisCacheAdapter) Update

func (r *RedisCacheAdapter) Update(ctx context.Context, key string, value any) error

type Suffix

type Suffix string
const (
	SuffixNone Suffix = ""
)

type TypedCacheObject

type TypedCacheObject[T CacheableObject[T]] struct {
	// contains filtered or unexported fields
}

func NewTypedObjectCache

func NewTypedObjectCache[T CacheableObject[T]](logger *slog.Logger, cache Cache, suffix Suffix) TypedCacheObject[T]

func (*TypedCacheObject[T]) Delete

func (d *TypedCacheObject[T]) Delete(ctx context.Context, obj T) error

func (*TypedCacheObject[T]) Get

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

func (*TypedCacheObject[T]) Store

func (d *TypedCacheObject[T]) Store(ctx context.Context, obj T) error

func (*TypedCacheObject[T]) Update

func (d *TypedCacheObject[T]) Update(ctx context.Context, obj T) error

Jump to

Keyboard shortcuts

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