cache

package
v0.0.0-...-ec10a6c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2024 License: GPL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[T any] struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache[T any](resolve func(string) (T, time.Duration)) *Cache[T]

func (*Cache[T]) Clear

func (c *Cache[T]) Clear()

func (*Cache[T]) Get

func (c *Cache[T]) Get(key string) (entry CacheEntry[T], cached bool)

func (*Cache[T]) GetRawValue

func (c *Cache[T]) GetRawValue(key string) (value T)

func (*Cache[T]) GetValue

func (c *Cache[T]) GetValue(key string) (value T, cached bool)

func (*Cache[T]) Remove

func (c *Cache[T]) Remove(key string)

func (*Cache[T]) Size

func (c *Cache[T]) Size() int

type CacheEntry

type CacheEntry[T any] struct {
	Value    T
	CachedAt time.Time
	TTL      time.Duration
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL