filesys

package
v0.0.0-...-9463477 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FileCachePath   = "cache"     // cache directory
	FileCacheExpire time.Duration // cache expire time, default is no expire forever.
)

Functions

This section is empty.

Types

type Cache

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

a cache for file storage.

func MustNewFileSysStore

func MustNewFileSysStore(baseDir string, interval time.Duration, serializer cache.Serializer) *Cache

MustNewFileSysStore an initialized Filesystem Cache If a non-existent directory is passed, it would be created automatically. Panics if the directory could not be created

func (*Cache) ClearAll

func (f *Cache) ClearAll() error

ClearAll will clean cached files.

func (*Cache) Delete

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

Delete file cache value.

func (*Cache) Get

func (f *Cache) Get(key string) ([]byte, error)

Get value from file cache. if non-exist or expired, return nil, error. run garbage collection with the key if necessary

func (*Cache) IsExist

func (f *Cache) IsExist(key string) bool

IsExist check value is exist.

func (*Cache) Put

func (f *Cache) Put(key string, data []byte, expire time.Duration) error

Put value into file cache. expire means how long to keep this file, unit of ms. if expire equals 0, cache this item forever.

func (*Cache) TrashGc

func (f *Cache) TrashGc(interval time.Duration)

Jump to

Keyboard shortcuts

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