cacher

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package cacher defines utilities for saving and restoring caches from Google Cloud storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cacher

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

Cacher is responsible for saving and restoring caches.

func New

func New(ctx context.Context) (*Cacher, error)

New creates a new cacher capable of saving and restoring the cache.

func (*Cacher) Debug added in v0.1.1

func (c *Cacher) Debug(val bool)

Debug enables or disables debugging for the cacher.

func (*Cacher) HashFiles added in v0.1.1

func (c *Cacher) HashFiles(files []string) (string, error)

HashFiles hashes the list of file and returns the hex-encoded SHA256.

func (*Cacher) HashGlob added in v0.1.1

func (c *Cacher) HashGlob(pattern string) (string, error)

HashGlob hashes the files matched by the given glob.

func (*Cacher) Restore

func (c *Cacher) Restore(ctx context.Context, i *RestoreRequest) (retErr error)

Restore restores the key from the cache into the dir on disk.

func (*Cacher) Save

func (c *Cacher) Save(ctx context.Context, i *SaveRequest) (retErr error)

Save caches the given directory in storage.

type RestoreRequest

type RestoreRequest struct {
	// Bucket is the name of the bucket from which to cache.
	Bucket string

	// Keys is the ordered list of keys to restore.
	Keys []string

	// Dir is the directory on disk to cache.
	Dir string
}

RestoreRequest is used as input to the Restore operation.

type SaveRequest

type SaveRequest struct {
	// Bucket is the name of the bucket from which to cache.
	Bucket string

	// Key is the cache key.
	Key string

	// Dir is the directory on disk to cache.
	Dir string
}

SaveRequest is used as input to the Save operation.

Jump to

Keyboard shortcuts

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