cache

package
v0.0.0-...-876207e Latest Latest
Warning

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

Go to latest
Published: May 31, 2017 License: GPL-3.0 Imports: 12 Imported by: 0

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 a facility to temporarily store images on disk for later retrival.

func NewCache

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

NewCache creates a new cache, backed by subdirectory 'subdir' inside the cache directory. The cache is pre-populated with any images found in this directory.

func (*Cache) Close

func (c *Cache) Close(pruneLimit int64) error

Close must be called when the cache is no longer needed. Up to 'pruneLimit' bytes of images may be left behind in the cache directory; these files will be used to pre-populate future Cache instances.

If pruneLimit >= 0, images added using the current Cache instance will always be retained, even if their total size exceeds pruneLimit. If pruneLimit < 0, all cached data is removed.

func (*Cache) Get

func (c *Cache) Get(key string) (image.Image, error)

Get returns an image which has previously been stored in the cache for the given key.

func (*Cache) Has

func (c *Cache) Has(key string) bool

Has returns true, if the cache contains an image which has previously been stored for the given key. The image can be retrieved using the .Get() method.

func (*Cache) Put

func (c *Cache) Put(key string, img image.Image) (err error)

Put stores a new image in the cache. The image can later be retrieved using the given key. Any preexisting image using the same key is overwritten by subsequent calls to .Put().

Jump to

Keyboard shortcuts

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