Documentation
¶
Index ¶
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 }
func Cacheable ¶
func Cacheable[K comparable, V any](getter func(key K) V, ttl *time.Duration) Cache[K, V]
Cacheable is the main function that should be used as func getter(key string) string { ... the original getter function ... } var ttl = 1 * time.Minute var cache = cacheable.Cacheable(getter, &ttl) func Get(key string) string { return cache.get(key) }
func (*Cache[K, V]) Delete ¶
func (c *Cache[K, V]) Delete(k K)
Delete deletes the key from the cache.
func (*Cache[K, V]) Get ¶
func (c *Cache[K, V]) Get(k K) V
Get returns a value at the given key. It is non-null safe method, so be sure to use Exists before getting the value.
Click to show internal directories.
Click to hide internal directories.