Documentation ¶
Overview ¶
Package cache provides the blob cache.
File name convention:
blobs/sha256/*.tmp: tmp files
blobs/sha256/<SHA256>: verified blobs
metadata/sha256/<SHA256> : metadata of the blob (optional)
digests/by-url-sha256/<SHA256-OF-URL> : digest of the blob (optional, note that URL is not always unique)
Index ¶
- Constants
- func ValidateMetadata(m *Metadata) error
- type Cache
- func (c *Cache) BlobAbsPath(sha256sum string) (string, error)
- func (c *Cache) BlobRelPath(sha256sum string) (string, error)
- func (c *Cache) Cached(sha256sum string) (bool, error)
- func (c *Cache) Dir() string
- func (c *Cache) Ensure(ctx context.Context, u *url.URL, sha256sum string, m *Metadata) error
- func (c *Cache) Export(dir string) (map[string]string, error)
- func (c *Cache) Import(dirOrFiles ...string) (map[string]string, error)
- func (c *Cache) ImportWithReader(r io.Reader) (sha256sum string, err error)
- func (c *Cache) ImportWithURL(u *url.URL, m *Metadata) (sha256sum string, err error)
- func (c *Cache) MetadataBySHA256(sha256sum string) (*Metadata, error)
- func (c *Cache) MetadataFileAbsPath(sha256sum string) (string, error)
- func (c *Cache) MetadataFileRelPath(sha256sum string) (string, error)
- func (c *Cache) ReverseURLFileAbsPath(u *url.URL) (string, error)
- func (c *Cache) ReverseURLFileRelPath(u *url.URL) (string, error)
- func (c *Cache) SHA256ByOriginURL(u *url.URL) (string, error)
- type Metadata
Constants ¶
const ( BlobsSHA256RelPath = "blobs/sha256" MetadataSHA256RelPath = "metadata/sha256" ReverseURLRelPath = "digests/by-url-sha256" )
Variables ¶
This section is empty.
Functions ¶
func ValidateMetadata ¶ added in v0.4.0
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func (*Cache) BlobRelPath ¶
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) Import ¶
Import imports local directories or files, and returns map[basename]sha256sum .
func (*Cache) ImportWithReader ¶
ImportWithReader imports from the reader. Does not create the metadata files.
func (*Cache) ImportWithURL ¶
func (*Cache) MetadataBySHA256 ¶ added in v0.4.0
MetadataBySHA256 returns the metadata for the blob. Not always available.