Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[TKey CacheKeyConstraint, TValue CacheValueConstraint] interface { // Check if the cache contains a value associated to a given key HasKey(k TKey) bool // Retrieve a value associated to a given key GetValue(k TKey) (TValue, error) // Add or overwrite a cached value associated to a given key. The return value indicates if the operation was successful SetValue(k TKey, v TValue) bool }
Utility used to cache values using key-value mapping
func CreateInMemoryCache ¶
func CreateInMemoryCache[TKey CacheKeyConstraint, TValue CacheValueConstraint](maxSize int) (Cache[TKey, TValue], error)
Create a new instance of a in-memory cache with a given cache size. If the size is set to 0 the cache will have not size limit
type CacheKeyConstraint ¶
type CacheKeyConstraint interface { comparable }
type CacheValueConstraint ¶
type CacheValueConstraint interface { any }
Click to show internal directories.
Click to hide internal directories.