cache

package
v2.0.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2016 License: MIT Imports: 4 Imported by: 38

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyCache = &emptyCache{}

EmptyCache represents a cache that never stores anything

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Get gets the data, returning nil if it isn't cached
	Get(key string) ([]byte, error)

	// Set saves data,
	Set(key string, data []byte) error
}

Cache represents a cache

func ConstCache

func ConstCache(data []byte) Cache

ConstCache creates a Cache that always returns the same data

func FileCache

func FileCache(dirname string) Cache

FileCache returns a cache that stores keys on filesystem

func FileCacheWithFormat

func FileCacheWithFormat(dirname string, format string) Cache

FileCacheWithFormat creates a FileCache that uses a format string to generate filenames

func FileCacheWithNameFn

func FileCacheWithNameFn(dirname string, filename func(string) string) Cache

FileCacheWithNameFn creates a FileCache that has a custom function to generate filenames

func MemoryCache

func MemoryCache() Cache

MemoryCache returns a cache that stores keys in memory

func WriteTroughCache

func WriteTroughCache(dirname string) Cache

WriteTroughCache creates a cache that stores keys in memory and uses disk as fallback

func WriteTroughCacheWithFormat

func WriteTroughCacheWithFormat(dirname, format string) Cache

WriteTroughCacheWithFormat creates a cache that stores keys in memory and uses disk as fallback and that generates filenames based on the format

func WriteTroughCacheWithNameFn

func WriteTroughCacheWithNameFn(dirname string, fn func(string) string) Cache

WriteTroughCacheWithNameFn creates a cache that stores keys in memory and uses disk as fallback. It generates filenames based on the passed in function.

Jump to

Keyboard shortcuts

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