cache

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package cache implements spok's mechanism for storing and retrieving the cached SHA256 digest for a spok task.

Index

Constants

View Source
const (
	Dir  string = ".spok"      // Dir is the directory under which the spok cache is kept
	File string = "cache.json" // File is filename of the spok cache file

)

Variables

View Source
var Path = filepath.Join(Dir, File) // Path is the whole filepath to the spok cache file

Functions

func Exists

func Exists(path string) bool

Exists returns whether or not the spok cache exists at all, e.g. if spok has not been run before.

func Init

func Init(path string, names ...string) error

Init populates the entire .spok cache directory and writes a placeholder cache file containing the names of all the tasks but no digests.

Types

type Cache

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

Cache represents the entire spok cache.

func Load

func Load(path string) (*Cache, error)

Load reads in the current cache state from file.

func New

func New() *Cache

New creates and returns an empty cache.

func (*Cache) Dump

func (c *Cache) Dump(path string) error

Dump saves the cache to disk.

func (*Cache) Get

func (c *Cache) Get(name string) (string, bool)

Get retrieves the digest value for a given name as well as a bool `ok` for whether or not it was found.

func (*Cache) Set

func (c *Cache) Set(name, digest string)

Set sets the digest value for a given name.

Jump to

Keyboard shortcuts

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