zfilecache

package
v0.0.0-...-0521b85 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	WorkDir string

	ServeEmptyImage    bool
	DeleteAfter        time.Duration // Delete files when modified more than this long ago
	UseToken           bool          // Not implemented
	DeleteRatio        float32       // When deleting files, only do some of sub-folders (randomly) each time 0.1 is do 10% of them at random
	NestInHashFolders  bool
	InterceptServeFunc func(w http.ResponseWriter, req *http.Request, file *string) bool // return true if handled
	// contains filtered or unexported fields
}

func Init

func Init(router *mux.Router, workDir, urlPrefix, cacheName string) *Cache

func (*Cache) CacheFromData

func (c *Cache) CacheFromData(data []byte, name string) (string, error)

CacheFromData reads in data, using name as filename, or hash of data, and extension This string return is this name/hash, used to get a path or a url for fetching. This should really call CacheFromReader, not visa versa

func (*Cache) CacheFromReader

func (c *Cache) CacheFromReader(reader io.Reader, name string) (string, error)

CacheFromReader reads bytes from reader with stype png or jpeg and caches is with CacheFromData This name is used to get a path or a url for getting

func (*Cache) GetPathForName

func (c *Cache) GetPathForName(name string) (path, dir string)

func (*Cache) GetURLForName

func (c *Cache) GetURLForName(name string) string

func (*Cache) HandlerWithCheckToken

func (c *Cache) HandlerWithCheckToken(h http.Handler) http.Handler

func (*Cache) IsCached

func (c *Cache) IsCached(name string) bool

func (*Cache) IsTokenValid

func (c *Cache) IsTokenValid(t string) bool

func (*Cache) RemoveFileWithName

func (c *Cache) RemoveFileWithName(name string) error

func (Cache) ServeHTTP

func (c Cache) ServeHTTP(w http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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