Byteroo
Byteroo is a key-value storage for your Node.js applications.
Usage:
const Byteroo = require('byteroo');
const storage = new Byteroo({
name: 'mystorage',
path: '/path/to/storage',
});
const container = storage.getContainerSync('users');
/* or
const container = await storage.getContainer('sync');
*/
Property | Description |
---|---|
name | Name of your storage, used to automatically find a path in case it's not provided |
path | [optional] Path where all the containers will be stored, created automatically if doesn't exist |
// adding new value
container.set('[email protected]', 'value');
// retrieving a value
container.get('[email protected]'); // -> 'value'
// removing a value
container.remove('[email protected]');
// saving data to disk
container.commit();
Storing data in memory
You can store your data in memory by using the IN_MEMORY_STORAGE constant exported by the module.
const constants = require('byteroo/constants');
{
path: constants.IN_MEMORY_STORAGE;
}
This will disable the commit() function (you can still call it without any error) and the data won't be stored to disk.