Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

pmem/libpmemobj-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PROJECT NOT UNDER ACTIVE MANAGEMENT

This project will no longer be maintained by Intel.
This project has been identified as having known security escapes.
Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.
Intel no longer accepts patches to this project.

libpmemobj-js: Persistent Memory Development Kit for JavaScript*

The Persistent Memory Development Kit for JavaScript* (libpmemobj-js) is a project to provide a Node.js module to store JavaScript objects in persistent memory. One of the goal of the project is to make programming with persistent JavaScript objects feels natural to developer. We have implemented persistent JavaScript classes including PersistentObject, PersistentArray and PersistentArrayBuffer, however they are not fully performance-optimized. Please see our examples and API document for details.

This module uses the libpmemobj library from the Persistent Memory Development Kit (PMDK). For more information on PMDK, please visit http://pmem.io and https://github.com/pmem/pmdk.

Dependencies

  • Node.js 8.x or higher
  • PMDK - native persistent memory libraries
  • node-addon-api - header-only C++ wrapper classes which simplify the use of the C based N-API provided by Node.js
  • bindings - Helper module for loading native module's .node file
  • Use only for testing

BUILD & TEST

Get the Codes

$ git clone https://github.com/pmem/libpmemobj-js.git
$ cd libpmemobj-js

Build libpmemobj-js

You can build the dependency to PMDK by using our script, then install libpmemobj-js by npm

$ cd deps
$ ./buildall.sh
$ cd ../src
$ npm install

TEST

After build, you can run the tests by

$ LD_LIBRARY_PATH=/usr/local/lib mocha ../tests

Example

We are using memory to emulate a persistent memory.

const jspmdk = require('jspmdk');
const constants = jspmdk.constants;

// you should specify your own path to persistent memory here
var path = '/path/to/pmem/file';
var pool = jspmdk.new_pool(path, constants.MIN_POOL_SIZE);

var check = pool.check();
if (check == -1) {
  // not exists
  pool.create();
}
else if (check == 0) {
  // not consistent
}
else if (check == 1) {
  // exists and consistent
  pool.open();
}

var root = pool.root;
pool.root = undefined;

// persistent Object
var pobj = pool.create_object({a: 1});
var a = pobj.a;
pobj.b = 2;
delete pobj.b;

// persistent Array
var parr = pool.create_object([1, 2]);
if (parr.is_array()) {
  parr.push(3);
  parr.pop();
}

// persistent ArrayBuffer
var pab = pool.create_arraybuffer(new ArrayBuffer(10));
var pab_uint8 = new Uint8Array(pab);
pab_uint8[0] = 1;
pab.persist(0, 1)

// close object pool
pool.close();

About

JavaScript bindings for libpmemobj

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •