Versions in this module Expand all Collapse all v1 v1.5.0 Aug 11, 2026 v1.4.2 Aug 11, 2026 v1.4.1 Aug 11, 2026 v1.4.0 Aug 10, 2026 Changes in this version + const CodeInvalidConfig + const Version + func GetOrSet(ctx context.Context, c *Cache, key string, ttl time.Duration, ...) (any, error) + type Cache struct + func New(opts ...Option) (*Cache, error) + func (c *Cache) Cleanup() + func (c *Cache) Clear() + func (c *Cache) Close() + func (c *Cache) Delete(key string) bool + func (c *Cache) Get(key string) (any, bool) + func (c *Cache) Len() int + func (c *Cache) Set(key string, value any) + func (c *Cache) SetTTL(key string, value any, ttl time.Duration) + func (c *Cache) Stats() Stats + type CacheEvent struct + Action string + Err error + Key string + type EventHook interface + OnCacheEvent func(ctx context.Context, e CacheEvent) + type EvictReason uint8 + const EvictCapacity + const EvictExpired + func (r EvictReason) String() string + type Metrics = metricsx.Sink + type Option func(*config) + func WithCapacity(n int) Option + func WithCleanupInterval(d time.Duration) Option + func WithDefaultTTL(d time.Duration) Option + func WithEventHook(h EventHook) Option + func WithLRURefresh(interval int) Option + func WithMetrics(m Metrics) Option + func WithOnEvicted(fn func(key string, value any, reason EvictReason)) Option + func WithShards(n int) Option + func WithTraceHook(h TraceHook) Option + type Stats struct + Capacity int + Deletes uint64 + Evictions uint64 + Expired uint64 + Hits uint64 + Len int + Misses uint64 + Sets uint64 + type TraceAttr = tracex.TraceAttr + type TraceHook = tracex.TraceHook