phialcash
Simple in-memory file cache.
Installation
npm install phialcash
Example
var co = ;var fs = ; // or any generator friendly file system libraryvar config = fsLibrary: fs fsExistsMethod: 'exists' fsReadFileMethod: 'readFile';var fc = ;fc = config; var filePath = './tests/file.fixture.txt';var fileName = 'file.fixture.txt'; ;
API
new
fc(config)
phialcash expects a generator friendly file system library.
config.fsLibrary
- Reference to the file system libraryconfig.fsExistsMethod
- String representation of the method name that checks if a file existsconfig.fsReadFileMethod
- String representation of the method name that reads a file
fc.cache(filePath, fileName)
Caches the file at filePath
. filePath
, and fileName
are string.
fc.has(fileName)
Returns true if there is a cached version of fileName
; otherwise, returns false
. fileName
must be a file name string.
fc.get(fileName)
Returns the fileName
's contents from memory. fileName
must be a file name string.
fc.clear()
Clears the cache.