filecache

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: GPL-3.0 Imports: 6 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
}

TODO: Consider replacing this with golang-lru: https://github.com/hashicorp/golang-lru

func New

func New[T any](cap int, ttl time.Duration) *Cache[T]

func (*Cache[T]) Entry

func (c *Cache[T]) Entry(fileName string) Entry[T]

func (*Cache[T]) Invalidate

func (c *Cache[T]) Invalidate(fileName string)

func (*Cache[T]) IsStale

func (*Cache[T]) IsStale(
	fileName string, entry Entry[T],
) (bool, os.FileInfo, error)

func (*Cache[T]) Load

func (c *Cache[T]) Load(fileName string) (T, bool)

func (*Cache[T]) LoadLatest

func (c *Cache[T]) LoadLatest(
	fileName string, loader func() (T, error),
) (T, error)

func (*Cache[T]) StartEviction

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

func (*Cache[T]) Stop

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

func (*Cache[T]) StopEviction

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

func (*Cache[T]) Store

func (c *Cache[T]) Store(fileName string, data T, fi os.FileInfo)

type Entry

type Entry[T any] struct {
	Data         T
	Size         int64
	LastModified int64
	ExpiresAt    time.Time
}

Jump to

Keyboard shortcuts

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