Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OnEntryReloadedCallback ¶
type OnEntryReloadedCallback func(key string)
OnEntryReloadedCallback will be called if a prefetched entry is reloaded
type PrefetchingCacheOption ¶
type PrefetchingCacheOption[T any] func(c *PrefetchingExpiringLRUCache[cacheValue[T]])
type PrefetchingExpiringLRUCache ¶
type PrefetchingExpiringLRUCache[T any] struct { // contains filtered or unexported fields }
func NewPrefetchingCache ¶
func NewPrefetchingCache[T any](ctx context.Context, options PrefetchingOptions[T]) *PrefetchingExpiringLRUCache[T]
func (*PrefetchingExpiringLRUCache[T]) Clear ¶
func (e *PrefetchingExpiringLRUCache[T]) Clear()
Clear removes all cache entries
func (*PrefetchingExpiringLRUCache[T]) Get ¶
func (e *PrefetchingExpiringLRUCache[T]) Get(key string) (val *T, expiration time.Duration)
Get returns the value of cached entry with remained TTL. If entry is not cached, returns nil
func (*PrefetchingExpiringLRUCache[T]) Put ¶
func (e *PrefetchingExpiringLRUCache[T]) Put(key string, val *T, expiration time.Duration)
func (*PrefetchingExpiringLRUCache[T]) TotalCount ¶
func (e *PrefetchingExpiringLRUCache[T]) TotalCount() int
TotalCount returns the total count of valid (not expired) elements
type PrefetchingOptions ¶
type PrefetchingOptions[T any] struct { expirationcache.Options ReloadFn ReloadEntryFn[T] PrefetchThreshold int PrefetchExpires time.Duration PrefetchMaxItemsCount int OnPrefetchAfterPut expirationcache.OnAfterPutCallback OnPrefetchEntryReloaded OnEntryReloadedCallback OnPrefetchCacheHit expirationcache.OnCacheHitCallback }
Click to show internal directories.
Click to hide internal directories.