filecache

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2017 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ConfigKeyBasepath = "basepath"
	ConfigKeyMaxZoom  = "max_zoom"
)
View Source
const CacheType = "file"

Variables

View Source
var (
	ErrMissingBasepath = errors.New("filecache: missing required param 'basepath'")
	ErrCacheMiss       = errors.New("filecache: cache miss")
)

Functions

func New

func New(config map[string]interface{}) (cache.Interface, error)

New instantiates a Filecache. The config expects the following params:

basepath (string): a path to where the cache will be written
max_zoom (int): max zoom to use the cache. beyond this zoom cache Set() calls will be ignored

Types

type Filecache

type Filecache struct {
	Basepath string

	//	we need a cache mutex to avoid concurrent writes to our Locker
	sync.RWMutex

	//	Locker tracks which cache keys are being operated on.
	//	when the cache is being written to a Lock() is set.
	//	when being read from an RLock() is used so we don't
	//	block concurrent reads.
	//
	//	TODO: store a hash of the cache blob along with the Locker mutex
	Locker map[string]sync.RWMutex

	//	MaxZoom determins the max zoom the cache to persist. Beyond this
	//	zoom, cache Set() calls will be ignored. This is useful if the cache
	//	should not be leveraged for higher zooms when data changes often.
	MaxZoom *uint
}

func (*Filecache) Get

func (fc *Filecache) Get(key *cache.Key) ([]byte, bool, error)

Get reads a z,x,y entry from the cache and returns the contents if there is a hit. the second argument denotes a hit or miss so the consumer does not need to sniff errors for cache read misses

func (*Filecache) Purge

func (fc *Filecache) Purge(key *cache.Key) error

func (*Filecache) Set

func (fc *Filecache) Set(key *cache.Key, val []byte) error

Jump to

Keyboard shortcuts

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