cache

package
v0.0.0-...-02fe4d0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2016 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache provides access to entries in the cache.

func NewCache

func NewCache(directory string) (*Cache, error)

NewCache creates a new cache in the specified directory.

func (*Cache) Close

func (c *Cache) Close()

Close waits for all downloaders to complete before shutting down.

func (*Cache) GetReader

func (c *Cache) GetReader(rawurl string, maxAge time.Duration) (Reader, error)

GetReader obtains a Reader for the specified rawurl. If a downloader currently exists for the URL, a live reader is created and connected to it. If the URL exists in the cache, it is read using the standard file API. If not, a downloader and live reader are created.

func (*Cache) Insert

func (c *Cache) Insert(rawurl string, r io.Reader) error

Insert adds an item into the cache.

type DownloadError

type DownloadError struct {
	Status string
}

DownloadError conveys information about a download request that failed.

func (*DownloadError) Error

func (d *DownloadError) Error() string

Error returns a description of the error.

type Entry

type Entry struct {
	URL           string `json:"url"`
	Complete      bool   `json:"complete"`
	ContentLength string `json:"content_length"`
	ContentType   string `json:"content_type"`
	LastModified  string `json:"last_modified"`
}

Entry represents an individual item in the cache.

func (*Entry) Load

func (e *Entry) Load(filename string) error

Load reads the entry from disk.

func (*Entry) Save

func (e *Entry) Save(filename string) error

Save writes the entry to disk.

type Reader

type Reader interface {
	io.ReadCloser
	GetEntry() (*Entry, error)
}

Reader is a generic interface for reading cache entries either from disk or directly attached to a downloader.

Jump to

Keyboard shortcuts

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