diskcache

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package diskcache implements disk backed cache storage for use in greenhouse

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 implements disk backed cache storage

func NewCache

func NewCache(diskRoot string) *Cache

NewCache returns a new Cache given the root directory that should be used on disk for cache storage

func (*Cache) Delete

func (c *Cache) Delete(key string) error

Delete deletes the file at key

func (*Cache) DiskRoot

func (c *Cache) DiskRoot() string

DiskRoot returns the root directory containing all on-disk cache entries

func (*Cache) Get

func (c *Cache) Get(key string, readHandler ReadHandler) error

Get provides your readHandler with the contents at key

func (*Cache) GetEntries

func (c *Cache) GetEntries() []EntryInfo

GetEntries walks the cache dir and returns all paths that exist In the future this *may* be made smarter

func (*Cache) KeyToPath

func (c *Cache) KeyToPath(key string) string

KeyToPath converts a cache entry key to a path on disk

func (*Cache) PathToKey

func (c *Cache) PathToKey(key string) string

PathToKey converts a path on disk to a key, assuming the path is actually under DiskRoot() ...

func (*Cache) Put

func (c *Cache) Put(key string, content io.Reader, contentSHA256 string) error

Put copies the content reader until the end into the cache at key if contentSHA256 is not "" then the contents will only be stored in the cache if the content's hex string SHA256 matches

type EntryInfo

type EntryInfo struct {
	Path       string
	LastAccess time.Time
}

EntryInfo are returned when getting entries from the cache

type ReadHandler

type ReadHandler func(exists bool, contents io.ReadSeeker) error

ReadHandler should be implemented by cache users for use with Cache.Get

Jump to

Keyboard shortcuts

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