Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/heapwolf/readfilecache

does exactly what you think it does
https://github.com/heapwolf/readfilecache

Last synced: 25 days ago
JSON representation

does exactly what you think it does

Awesome Lists containing this project

README

        

# SYNOPSIS
Returns data from fs.readFile or memory conditional on the mtime from an fs.stat.

# USAGE
```js
//
// create a cache instance
//
var cache = require('readfilecache')()

//
// read a file, a call to the same path will return
// the data from memory if the mtime is the same
// on the file as it is in memory.
//

cache.readFile(filename, function(err, data, stat) {
// err or null, the data from the file and the stat info
})

//
// supports a sync api as well
//
cache.readFileSync(filename) // returns the file

//
// clear the cache
//
cache.invalidate()
```