Home

Awesome

random-access-page-files

An abstract-random-access backend that writes to fixed size page files instead of a single file. Useful for sparse data.

npm install random-access-page-files

build status

Usage

var pages = require('random-access-page-files')

var storage = pages('a-folder', {
  pageSize: 5 * 1024 * 1024 // use 5mb pages
})

// will write use single page file < 5mb
storage.write(222852525, new Buffer('hello'), function (err) {
  if (err) throw err
  storage.read(222852525, 5, function (err, buf) {
    if (err) throw err
    console.log(buf)
  })
})

API

var storage = pages(folder, [options])

Create a new storage provider. Options include:

{
  pageSize: 5 * 1024 * 1024, // how big are the page files?
  limit: 16 // how many open files at max?
}

License

MIT