Documentation
¶
Overview ¶
Package memory provides an in-memory LRU cache with TTL expiration.
Index ¶
- type MemoryCache
- func (mc *MemoryCache) Clear(ctx context.Context) error
- func (mc *MemoryCache) Delete(ctx context.Context, key string) error
- func (mc *MemoryCache) Get(ctx context.Context, key string) (any, error)
- func (mc *MemoryCache) Set(ctx context.Context, key string, value any, ttl time.Duration) error
- func (mc *MemoryCache) Stats() *port.CacheStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache implements port.CachePort with LRU eviction
func NewMemoryCache ¶
func NewMemoryCache(maxSize int, ttl time.Duration) *MemoryCache
NewMemoryCache creates a new in-memory cache with LRU eviction
func (*MemoryCache) Clear ¶
func (mc *MemoryCache) Clear(ctx context.Context) error
Clear removes all entries from cache
func (*MemoryCache) Delete ¶
func (mc *MemoryCache) Delete(ctx context.Context, key string) error
Delete removes a key from cache
func (*MemoryCache) Stats ¶
func (mc *MemoryCache) Stats() *port.CacheStats
Stats returns cache statistics
Click to show internal directories.
Click to hide internal directories.