Documentation
¶
Overview ¶
Package cache provides a key-value cache contract with in-memory TTL and Redis backends for gRPC middleware caching.
Index ¶
- func NewRedisStore(addr string) IOE.IOEither[error, Store]
- type MemoryStore
- func (m *MemoryStore) Close() error
- func (m *MemoryStore) Delete(_ context.Context, key string) IOE.IOEither[error, struct{}]
- func (m *MemoryStore) Get(_ context.Context, key string) IOE.IOEither[error, O.Option[[]byte]]
- func (m *MemoryStore) Set(_ context.Context, key string, val []byte, ttl time.Duration) IOE.IOEither[error, struct{}]
- type RedisStore
- func (r *RedisStore) Close() error
- func (r *RedisStore) Delete(ctx context.Context, key string) IOE.IOEither[error, struct{}]
- func (r *RedisStore) Get(ctx context.Context, key string) IOE.IOEither[error, O.Option[[]byte]]
- func (r *RedisStore) Set(ctx context.Context, key string, val []byte, ttl time.Duration) IOE.IOEither[error, struct{}]
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-memory TTL cache backed by ttlcache/v3.
func (*MemoryStore) Close ¶
func (m *MemoryStore) Close() error
Close clears all entries from the in-memory cache.
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore is a Redis-backed Store implementation using go-redis/v9.
func (*RedisStore) Close ¶
func (r *RedisStore) Close() error
Close closes the underlying Redis client connection.
type Store ¶
type Store interface {
Get(ctx context.Context, key string) IOE.IOEither[error, O.Option[[]byte]]
Set(ctx context.Context, key string, val []byte, ttl time.Duration) IOE.IOEither[error, struct{}]
Delete(ctx context.Context, key string) IOE.IOEither[error, struct{}]
Close() error
}
Store defines the functional key-value cache contract for serialized protobuf payloads.
func NewMemoryStore ¶
func NewMemoryStore() Store
NewMemoryStore creates an in-memory TTL cache store with touch-on-hit disabled so entries expire strictly after their configured TTL.
Click to show internal directories.
Click to hide internal directories.