Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/mafintosh/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.
https://github.com/mafintosh/random-access-page-files

Last synced: about 1 month ago
JSON representation

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

Awesome Lists containing this project

README

        

# random-access-page-files

An [abstract-random-access](https://github.com/juliangruber/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](http://img.shields.io/travis/mafintosh/random-access-page-files.svg?style=flat)](http://travis-ci.org/mafintosh/random-access-page-files)

## Usage

``` js
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:

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

## License

MIT