Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[V any] struct { // contains filtered or unexported fields }
Cache is an efficient cache with a TTL.
func NewCache ¶
func NewCache[V any](opts CacheOptions) *Cache[V]
NewCache returns a new cache with a TTL.
func (*Cache[V]) Cleanup ¶
func (c *Cache[V]) Cleanup()
Cleanup removes all expired entries from the cache.
func (*Cache[V]) Get ¶
Get returns an item from the cache. Items that have expired are not returned.
type CacheOptions ¶
type CacheOptions struct {
// Initial size for the cache.
// This is optional, and if empty will be left to the underlying library to decide.
InitialSize int32
// Interval to perform garbage collection.
// This is optional, and defaults to 150s (2.5 minutes).
CleanupInterval time.Duration
// Maximum TTL value in seconds, if greater than 0
MaxTTL int64
// contains filtered or unexported fields
}
CacheOptions are options for NewCache.
Click to show internal directories.
Click to hide internal directories.