Store fixed size values in an abstract-random-access compatible storage provider
npm install random-access-database
var rad = require('random-access-database')
var raf = require('random-access-file')
var db = rad(raf('db'), {valueLength: 5})
db.put(0, 'hello', function (err) {
if (err) throw err
db.get(0, function (err, val) {
if (err) throw err
console.log('stored at 0:', val)
})
})
Create a new databae. storage
should be an abstract-random-access compatible storage provider. Options include
{
valueEncoding: encodeValuesUsingThisEncoding,
valueLength: lengthOfAllValues,
offset: functionThatReturnsValueOffset
}
You must either set the valueLength
of offset
option. The offset
option is called with the numeric index of a value and should return the byte offset of this value.
Insert a value in the database.
Retrieve a value from the database. Callback is called with (err, value)
.
Delete a value from the database. Will blank it out in the underlying storage.
MIT