Help us shape the future of Go! Take the 2026 Go Developer Survey

fscache

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

README

fscache

👓 fscache is a simple, non-magical helper package for loading file-system content only once and using an in-memory cache for consecutive requests

GoDoc Go Report Card

Installation

To install fscache, simly run:

$ go get github.com/harwoeck/fscache

Documentation

Overview

Package fscache is a simple, non-magical helper package for loading file-system content only once and using an in-memory cache for consecutive requests

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FsCache

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

FsCache holds the caching structure and needed internals to cache file- system content.

func NewFsCache

func NewFsCache(isProduction bool) *FsCache

NewFsCache returns a new instance of FsCache

func (*FsCache) Load

func (fs *FsCache) Load(path string) (buf []byte, err error)

Load looks if the file is already in the internal memory-buffer cache. If so it returns it immediately, else the file is loaded, stored to the cache and returned. If the FsCache is in production mode the file is loaded from disk each time it's requested. This feature can be used if the underlying file-content changes during development.

func (*FsCache) Preload

func (fs *FsCache) Preload(path string) (err error)

Preload loads the file in path, it it exists, into the internal caching structure

func (*FsCache) PreloadBatch

func (fs *FsCache) PreloadBatch(paths []string) (err error)

PreloadBatch is like Preload but performs the operation for a full batch, while still only acquiring internal mutexes once.

Jump to

Keyboard shortcuts

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