cache

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

* Copyright (C) 2017-Present Pivotal Software, Inc. All rights reserved. * * This program and the accompanying materials are made available under * the terms of the under the Apache License, Version 2.0 (the "License”); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright (C) 2017-Present Pivotal Software, Inc. All rights reserved. * * This program and the accompanying materials are made available under * the terms of the under the Apache License, Version 2.0 (the "License”); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCache

func NewCache(progressWriter io.Writer) (*fileCache, error)

func NewEtagIndex

func NewEtagIndex(indexFile string) (*etagIndex, error)

Types

type Cache

type Cache interface {
	Entry(Url string) CacheEntry
}

Cache provides a cache of files indexed by their download URLs. Each cached file has an associated etag.

type CacheEntry

type CacheEntry interface {
	// Retrieve returns the fully qualified path of the cached file and its etag.  If the file has not been cached, the returned path is empty.
	Retrieve() (path string, etag string, err error)

	// Store writes the cached file contents and associates the given etag (which  may be empty) with the file.
	// If the file contents cannot be written or the etag associated with the file, an error is returned.
	// The file contents are checked against the given checksum using the given hash and an error is returned if the check fails.
	Store(contents io.ReadCloser, etag string, checksum string, hashFunc hash.Hash) error
}

CacheEntry provides a cache of a single file and its etag.

type ChecksumCalculator

type ChecksumCalculator interface {
	CalculateChecksum(filePath string, hashFunc hash.Hash) (string, error)
}

Place checksum calculator functionality inside an interface to help with testing

type EtagHelper

type EtagHelper interface {
	GetETagForUrl(url string) (string, error)
	SetEtagForUrl(url string, etag string) error
}

Place etag handling functionality inside an interface to help with testing

type IndexMap

type IndexMap map[string]string

Jump to

Keyboard shortcuts

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