cached

package
v0.0.0-...-d124ba8 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	*standard.File
	Key string
	FS  FileSystem
	// contains filtered or unexported fields
}

File Same as fs.File, but cache contents in memory

func (File) Close

func (cf File) Close() error

Close Close actual file if we needed it

func (File) Readdir

func (cf File) Readdir(n int) (fis []os.FileInfo, err error)

Readdir Wrapper around fs.File.Readdir

func (File) Serve

func (cf File) Serve(w http.ResponseWriter, r *http.Request)

Serve Write cached contents to http response

func (File) Stat

func (cf File) Stat() (os.FileInfo, error)

Stat Cached wrapper around os.File.Stat()

type FileSystem

type FileSystem struct {
	base.FileSystem
	Dir    string
	Cache  *bigcache.BigCache
	Logger *log.Entry
}

FileSystem is an http.FileSystem that hides hidden "dot files" from being served.

func NewFileSystem

func NewFileSystem() FileSystem

NewFileSystem Initialise new Cached Filesystem

func (FileSystem) GetCacheFallback

func (cfs FileSystem) GetCacheFallback(key string, populate func() ([]byte, error)) ([]byte, error)

GetCacheFallback Wrapper around bigcache.Get and Set

func (FileSystem) Open

func (cfs FileSystem) Open(name string) (base.ServingFile, error)

Open is a wrapper around the Open method of the embedded FileSystem that serves a 403 permission error when name has a file or directory with whose name starts with a period in its path.

type Stat

type Stat struct {
	NameField    string
	SizeField    int64
	ModTimeField time.Time
	ModeField    os.FileMode
}

func (Stat) IsDir

func (s Stat) IsDir() bool

func (Stat) ModTime

func (s Stat) ModTime() time.Time

func (Stat) Mode

func (s Stat) Mode() os.FileMode

func (Stat) Name

func (s Stat) Name() string

func (Stat) Size

func (s Stat) Size() int64

func (Stat) Sys

func (s Stat) Sys() interface{}

Jump to

Keyboard shortcuts

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