Skip to content

annamarcink/pmemkv-nodejs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pmemkv-nodejs

Node.js bindings for pmemkv

This is experimental pre-release software and should not be used in production systems. APIs and file formats may change at any time without preserving backwards compatibility. All known issues and limitations are logged as GitHub issues.

Dependencies

Installation

Start by installing pmemkv on your system.

Add npm module to your project:

npm install pmem/pmemkv-nodejs --save

Testing

This library includes a set of automated tests that exercise all functionality.

npm test

Example

We are using /dev/shm to emulate persistent memory in this simple example.

const pmemkv = require('pmemkv');

function assert(condition) {
    if (!condition) throw new Error('Assert failed');
}

console.log('Starting engine');
const kv = new KVEngine('vsmap', '{"path":"/dev/shm/"}');

console.log('Putting new key');
kv.put('key1', 'value1');
assert(kv.count === 1);

console.log('Reading key back');
assert(kv.get('key1') === 'value1');

console.log('Iterating existing keys');
kv.put('key2', 'value2');
kv.put('key3', 'value3');
kv.all((k) => console.log(`  visited: ${k}`));

console.log('Removing existing key');
kv.remove('key1');
assert(!kv.exists('key1'));

console.log('Stopping engine');
kv.stop();

About

NodeJS bindings for pmemkv

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 57.4%
  • C++ 41.4%
  • Python 1.2%