Documentation
¶
Overview ¶
Package memory provides a simple concurrent in-memory cache with TTL.
Index ¶
- type Cache
- func (c *Cache[K, V]) Clear(ctx context.Context) error
- func (c *Cache[K, V]) Close() error
- func (c *Cache[K, V]) Delete(ctx context.Context, key K) error
- func (c *Cache[K, V]) Exists(ctx context.Context, key K) (bool, error)
- func (c *Cache[K, V]) Get(ctx context.Context, key K) (V, error)
- func (c *Cache[K, V]) Len() int
- func (c *Cache[K, V]) Set(ctx context.Context, key K, value V, ttl time.Duration) error
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[K comparable, V any] struct { // contains filtered or unexported fields }
Cache is a plain map-backed cache (no eviction besides TTL).
type Option ¶
type Option func(*config)
Option configures a memory cache.
func WithCleanupInterval ¶
WithCleanupInterval sets expired-entry purge interval. 0 disables background GC.
func WithDefaultTTL ¶
WithDefaultTTL sets the default TTL used when Set is called with ttl == 0.
Click to show internal directories.
Click to hide internal directories.