filecache

package
v2.5.5 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: GPL-3.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFilename added in v2.4.0

func GetFilename(data []byte) string

Types

type Cache

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

func New

func New(basePath string) Cache

New creates and returns a new file-backed data caching instance.

func (Cache) AddFile

func (c Cache) AddFile(data []byte) string

AddFile saves the given data to a file in HOME/files directory using sha256 sum as filename.

func (Cache) GetFile

func (c Cache) GetFile(filename string) ([]byte, error)

GetFile loads the file from the file storage. Returns error if the file does not exist.

func (Cache) MustGetFile

func (c Cache) MustGetFile(filename string) []byte

MustGetFile loads the file from the file storage. Panics if the file does not exist.

Jump to

Keyboard shortcuts

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