cache

package
v0.1.3 Latest Latest
Warning

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

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

Documentation

Overview

Package cache provides the blob cache.

File name convention:

  • blobs/sha256/*.tmp: tmp files

  • blobs/sha256/<SHA256>: verified blobs

  • urls/sha256/<SHA256> : URL of the blob (optional)

  • digests/by-url-sha256/<SHA256-OF-URL> : digest of the blob (optional)

Index

Constants

View Source
const (
	BlobsSHA256RelPath = "blobs/sha256"
	URLsSHA256RelPath  = "urls/sha256"
	ReverseURLRelPath  = "digests/by-url-sha256"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func New

func New(dir string) (*Cache, error)

func (*Cache) BlobAbsPath

func (c *Cache) BlobAbsPath(sha256sum string) (string, error)

func (*Cache) BlobRelPath

func (c *Cache) BlobRelPath(sha256sum string) (string, error)

BlobRelPath returns a clean relative path like "blobs/sha256/<SHA256>". The caller should append this path to c.Dir(). The returned path may not exist. If it exists, its digest must have been already verified.

func (*Cache) Cached

func (c *Cache) Cached(sha256sum string) (bool, error)

func (*Cache) Dir

func (c *Cache) Dir() string

func (*Cache) Ensure

func (c *Cache) Ensure(ctx context.Context, u *url.URL, sha256sum string) error

func (*Cache) Export

func (c *Cache) Export(dir string) (map[string]string, error)

func (*Cache) Import

func (c *Cache) Import(dirOrFiles ...string) (map[string]string, error)

Import imports local directories or files, and returns map[basename]sha256sum .

func (*Cache) ImportWithReader

func (c *Cache) ImportWithReader(r io.Reader) (sha256sum string, err error)

ImportWithReader imports from the reader. Does not create the URL file.

func (*Cache) ImportWithURL

func (c *Cache) ImportWithURL(u *url.URL) (sha256sum string, err error)

func (*Cache) OriginURLBySHA256

func (c *Cache) OriginURLBySHA256(sha256sum string) (*url.URL, error)

OriginURLBySHA256 returns the origin of the blob. Not always available.

func (*Cache) ReverseURLFileAbsPath

func (c *Cache) ReverseURLFileAbsPath(u *url.URL) (string, error)

func (*Cache) ReverseURLFileRelPath

func (c *Cache) ReverseURLFileRelPath(u *url.URL) (string, error)

func (*Cache) SHA256ByOriginURL

func (c *Cache) SHA256ByOriginURL(u *url.URL) (string, error)

SHA256ByOriginURL returns the sha256sum by the origin URL. Not always available.

func (*Cache) URLFileAbsPath

func (c *Cache) URLFileAbsPath(sha256sum string) (string, error)

func (*Cache) URLFileRelPath

func (c *Cache) URLFileRelPath(sha256sum string) (string, error)

Jump to

Keyboard shortcuts

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