Documentation
¶
Overview ¶
Package cache provides optional Valkey read-through caching (W33-01–02).
Index ¶
- type IncrStore
- type MemoryStore
- func (s *MemoryStore) Delete(_ context.Context, key string)
- func (s *MemoryStore) Get(_ context.Context, key string) ([]byte, bool)
- func (s *MemoryStore) Incr(_ context.Context, key string, ttl time.Duration) (int64, error)
- func (s *MemoryStore) Set(_ context.Context, key string, value []byte, ttl time.Duration)
- type Store
- type ValkeyStore
- func (v *ValkeyStore) Delete(ctx context.Context, key string)
- func (v *ValkeyStore) Get(ctx context.Context, key string) ([]byte, bool)
- func (v *ValkeyStore) Incr(ctx context.Context, key string, ttl time.Duration) (int64, error)
- func (v *ValkeyStore) Set(ctx context.Context, key string, value []byte, ttl time.Duration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IncrStore ¶
type IncrStore interface {
Store
// Incr increments key by 1, sets TTL when key is new or on each bump when ttl > 0, returns new value.
Incr(ctx context.Context, key string, ttl time.Duration) (int64, error)
}
IncrStore optionally supports atomic increment (Valkey INCR / memory mutex). Used for cluster lockout and rate-limit counters (W76 residual).
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-process cache used when Valkey is unavailable.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
NewMemoryStore constructs an in-memory cache fallback.
type Store ¶
type Store interface {
Get(ctx context.Context, key string) ([]byte, bool)
Set(ctx context.Context, key string, value []byte, ttl time.Duration)
Delete(ctx context.Context, key string)
}
Store abstracts cache get/set/invalidate.
func NewValkeyStore ¶
NewValkeyStore constructs a cache with optional Valkey backend. URL format: valkey://host:port or host:port. Empty URL uses in-memory cache only.
type ValkeyStore ¶
type ValkeyStore struct {
// contains filtered or unexported fields
}
ValkeyStore uses a Valkey-compatible RESP server when URL is set; falls back to memory.
Click to show internal directories.
Click to hide internal directories.