Skip to content

annamarcink/pmemkv-java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pmemkv-java

Java 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

  • Java 8 or higher
  • PMDK - native persistent memory libraries
  • pmemkv - native key/value library
  • pmemkv-jni - JNI integration library
  • Used only for development & testing:

Installation

Start by installing pmemkv on your system.

Next install pmemkv-jni.

Finish by installing these bindings:

mvn install

Testing

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

mvn test

Example

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

import io.pmem.pmemkv.KVEngine;

public class Example {
    public static void main(String[] args) {
        System.out.println("Starting engine");
        KVEngine kv = new KVEngine("vsmap", "{\"path\":\"/dev/shm/\"}");

        System.out.println("Putting new key");
        kv.put("key1", "value1");
        assert kv.count() == 1;

        System.out.println("Reading key back");
        assert kv.get("key1").equals("value1");

        System.out.println("Iterating existing keys");
        kv.put("key2", "value2");
        kv.put("key3", "value3");
        kv.all((String k) -> System.out.println("  visited: " + k));

        System.out.println("Removing existing key");
        kv.remove("key1");
        assert !kv.exists("key1");

        System.out.println("Stopping engine");
        kv.stop();
    }
}

About

Java bindings for pmemkv

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%