Documentation
¶
Overview ¶
Package cache provides an in-memory caching layer for the HTTP server. It uses patrickmn/go-cache for TTL-based caching with LRU-like eviction.
Index ¶
- type Cache
- func (c *Cache) ActivateGeneration(sequence uint64, generationID string)
- func (c *Cache) Clear()
- func (c *Cache) Delete(key string)
- func (c *Cache) GenerationID() string
- func (c *Cache) Get(key string) (any, bool)
- func (c *Cache) GetGeneration(sequence uint64, generationID, key string) (any, bool)
- func (c *Cache) GetStats() Stats
- func (c *Cache) ItemCount() int
- func (c *Cache) Set(key string, value any)
- func (c *Cache) SetGeneration(sequence uint64, generationID, key string, value any)
- func (c *Cache) SetWithTTL(key string, value any, ttl time.Duration)
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache wraps go-cache with additional features for HTTP caching.
func New ¶
New creates a cache with the given default TTL and cleanup interval. The TTL sets entry expiration. The cleanup interval controls expired-entry removal.
func (*Cache) ActivateGeneration ¶ added in v0.1.0
ActivateGeneration atomically changes the visible namespace and removes old entries. Repeating the same generation is a no-op.
func (*Cache) GenerationID ¶ added in v0.1.0
GenerationID returns the active cache namespace.
func (*Cache) GetGeneration ¶ added in v0.1.0
GetGeneration retrieves a key only from generationID. The first request may initialize an empty cache, but an in-flight old request cannot reactivate a superseded namespace.
func (*Cache) SetGeneration ¶ added in v0.1.0
SetGeneration stores a key in the active generation namespace.