cache

package
v0.0.0-...-ff708c0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 13 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 {
	DataMutex sync.RWMutex
	Data      T
	Updated   time.Time
	// contains filtered or unexported fields
}

func New

func New[T any](name string, data T) *Cache[T]

func (*Cache[T]) ServeHTTP

func (c *Cache[T]) ServeHTTP() http.HandlerFunc

func (*Cache[T]) Update

func (c *Cache[T]) Update(data T)

func (*Cache[T]) UpdatePeriodically

func (c *Cache[T]) UpdatePeriodically(update func() (T, error), interval time.Duration)

type CacheResponse

type CacheResponse[T any] struct {
	Data    T         `json:"data"`
	Updated time.Time `json:"updated"`
}

Jump to

Keyboard shortcuts

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