Skip to content

greggman/inmemfilecache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

inmemfilecache

A very simple in memory file cache for node.js. It's a drop in replacement for fs.readFile and fs.readSyncFile

Build Status

Files are cached LRU style in memory. By default inmemfilecache monitors the folders of files in the cache. If a file changes it's removed from the cache. This means you can use it in dev environments and not have to disable it while your server is running.

Usage

var Cache = require('inmemfilecache');
var cache = new Cache();

cache.readFile('/path/to/file', callback);

API

  • Cache(options)

    options are optional

    • cacheSizeLimit

      the number of bytes the cache can hold. Defaults to 64 meg.

    • checkForFileChanges

      removes files from cache if the file changes. Default = true

  • Cache.readFile

    See fs.readFile

  • Cache.readFileSync

    See fs.readFileSync

  • Cache.setCacheLimit

    Changes the cache's size limit. If it's over this limit things will be removed from the cache until it's under the limit.

  • Cache.clear

    clears the cache and all folder trackers.

Notes:

Your app will not exit as along as folders are being tracked. Call cache.clear to clear all folder trackers.

About

A simple in memory file cache for node.

Resources

Stars

Watchers

Forks

Packages

No packages published