Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[K comparable, T any] interface { Get(key K) (T, bool, error) Set(key K, value T) error Del(key K) error Clear() error Len() (int64, error) }
func NewInMemoryCache ¶
NewInMemoryCache creates a new in-memory cache with the given name and TTL. It is a strong reference cache, meaning that values are kept in memory until explicitly deleted or the cache is cleared. It uses a sync.Map for thread-safe operations. Expired entries are removed upon access, so to keep the cache size optimal, periodic cleanup is recommended.
func NewInMemoryWeakCache ¶ added in v0.7.0
NewInMemoryWeakCache creates a new in-memory weak cache with the given name and TTL. It serializes values using msgpack to remove the strong references, but this incurs serialization overhead.
Click to show internal directories.
Click to hide internal directories.