Documentation
¶
Index ¶
- type Cache
- type CacheableObject
- type RedisCacheAdapter
- func (r *RedisCacheAdapter) Delete(ctx context.Context, key string) error
- func (r *RedisCacheAdapter) Get(ctx context.Context, key string, value any) error
- func (r *RedisCacheAdapter) Set(ctx context.Context, key string, value any, ttl time.Duration) error
- func (r *RedisCacheAdapter) Update(ctx context.Context, key string, value any) error
- type Suffix
- type TypedCacheObject
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 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
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)
Click to show internal directories.
Click to hide internal directories.