3.0.0 • Published 8 years ago

locking v3.0.0

Weekly downloads
57
License
-
Repository
github
Last release
8 years ago

locking

Build Status

Wraps any loader function of the form loader(id, callback) to use an LRU cache and lock I/O operations across concurrent calls.

var Locking = require('locking');
var fs = require('fs');
var readFile = Locking(fs.readFile);

// Reads file once, calls callback 10x.
for (var i = 0; i < 10; i++) {
    readFile('./sample.txt', function(err, data) {
        console.log(data);
    });
}