cachedisk

package
v0.20.3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: Apache-2.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 struct {
	// contains filtered or unexported fields
}

Cache implements a Cacher using the local filesystem.

func New

func New(workdir string, id string) (*Cache, error)

New returns a new Cache object.

The internal cache directory path is computed based on the provided workdir. The workdir will contain a hashed subfolder if a unique identifier is also provided.

func (*Cache) Has

func (c *Cache) Has(filename string) bool

Has returns whether the cache contains the file named by filename

func (*Cache) Invalidate

func (c *Cache) Invalidate(filename string) error

Invalidate invalidates a cache file named by filename

func (*Cache) Path

func (c *Cache) Path(filename string) string

Path returns the path to a cached file named by filename

func (*Cache) Read

func (c *Cache) Read(w io.Writer, filename string) error

Read reads a cached file named by filename and writes the contents to the provider w writer.

If the file does not exist, Read returns an error that satisfies errors.IsNotFound().

func (*Cache) Store

func (c *Cache) Store(r io.Reader, filename string) error

Store stores the provided bytes in a cache file named by filename

If the file exists, Store returns an error that satisfies errors.IsAlreadyExists(). Otherwise, Store creates it with permissions perm

func (*Cache) Writer

func (c *Cache) Writer(filename string) (*os.File, error)

Writer returns an io.Writer that writes to a cache file named by filename

Jump to

Keyboard shortcuts

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