Documentation
¶
Index ¶
- type CacheConfig
- type CacheLayer
- func (c *CacheLayer) Clear()
- func (c *CacheLayer) Delete(key string)
- func (c *CacheLayer) Get(key string) (any, bool)
- func (c *CacheLayer) GetOrSet(key string, loader func() (any, error)) (any, error)
- func (c *CacheLayer) GetOrSetWithTTL(key string, ttl time.Duration, loader func() (any, error)) (any, error)
- func (c *CacheLayer) Len() int
- func (c *CacheLayer) PurgeExpired() int
- func (c *CacheLayer) Set(key string, value any)
- func (c *CacheLayer) SetWithTTL(key string, value any, ttl time.Duration)
- func (c *CacheLayer) Stats() CacheStats
- type CacheStats
- type Conn
- type ConnFactory
- type ConnectionPool
- type ConnectionPoolConfig
- type ConnectionPoolStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheConfig ¶
type CacheConfig struct {
// MaxSize is the maximum number of items in the cache.
MaxSize int
// DefaultTTL is the default time-to-live for cache entries.
DefaultTTL time.Duration
}
CacheConfig configures the cache layer.
func DefaultCacheConfig ¶
func DefaultCacheConfig() CacheConfig
DefaultCacheConfig returns sensible defaults.
type CacheLayer ¶
type CacheLayer struct {
// contains filtered or unexported fields
}
CacheLayer implements a thread-safe cache with TTL expiration and LRU eviction. It follows the cache-aside pattern: callers check the cache first, then fall back to the source of truth and populate the cache on miss.