cache

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package cache provides functionality for managing a cache located on the file system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache represents a cache located on the file system.

func New

func New(options ...Option) (Cache, error)

New creates an uninitialized cache.

If location is an empty string the location will default to the user's home directory.

If ephemeral is set the cache will be located in a unique directory in the system's temporary directory (and the given location is ignored).

func (*Cache) Cleanup

func (c *Cache) Cleanup()

Cleanup the cache if it is ephemeral, removing it.

Any errors are silently ignored under the assumption that the temporary directory will be cleaned automatically.

func (*Cache) Clear

func (c *Cache) Clear() error

Clear the contents of the cache, removing everything.

func (*Cache) Evict

func (c *Cache) Evict() (uint, error)

Evict old entries from the cache, removing them.

func (*Cache) Init

func (c *Cache) Init() error

Init the cache.

func (*Cache) Path

func (c *Cache) Path() string

Path returns the path to the cache on the file system.

type Option added in v0.6.1

type Option func(Options) Options

Option is a function to configure the cache.

func WithEphemeralCache added in v0.6.1

func WithEphemeralCache(v bool) Option

WithEphemeralCache makes the cache ephemeral (single-run use).

func WithEviction added in v0.6.1

func WithEviction(v bool) Option

WithEviction enables or disabled cache evection.

func WithLocation added in v0.6.1

func WithLocation(v string) Option

WithLocation sets the location of the cache. The location is ignored when the cache is ephemeral.

type Options added in v0.6.1

type Options struct {
	Location  string
	Ephemeral bool
	Evict     bool
}

Options for a New cache.

Jump to

Keyboard shortcuts

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