Java NoSql Embeddable Database
If you need simple, persistable, fast and embeddable java nosql database you can use jnsedb just like this:
String dbDir = System.getProperty("user.dir") + "\.mydb";
String database = "mydatabase";
JnsedbManager dbManager = new JnsedbEmbeddedServer(dbDir).startup().getManager(database);
// store new entity
dbManager.store(myJavaObject);
// loads (lazy) all stored objects of class MyJavaObject
Collection<MyJavaObject> allMyJavaObjects = dbManager.loadAll(MyJavaObject.class);
// loads object of class MyJavaObject stored with id = 1
dbManager.load(MyJavaObject.class, 1);
// delete object of class MyJavaObject stored with id = 1
dbManager.delete(MyJavaObject.class, 1);
To use it in your maven project just add this code to your pom.xml file:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.itadvc</groupId>
<artifactId>jnsedb</artifactId>
<version>jnsedb-0.0.1</version>
</dependency>
gradle:
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.itadvc:jnsedb:jnsedb-0.0.1'
}
import com.github.itadvc.jnsedb.annotations.Cache;
import com.github.itadvc.jnsedb.annotations.Id;
@Cache
public class MyJavaObject {
@Id
private String internalId;
private int myIntValue;
private List<ChildClass> childs;
public String getInternalId() {
return internalId;
}
public void setInternalId(String id) {
this.internalId = internalId;
}
}
import com.github.itadvc.jnsedb.annotations.Cache;
@Cache(maxSizeMB = 10)
public class MyJavaObject {
...
import com.github.itadvc.jnsedb.annotations.Id;
public class MyJavaObject {
@Id
private int id;
...
import com.github.itadvc.jnsedb.annotations.Id;
public class MyJavaObject {
@Id(globalAutoincrement = true)
private int id;
...
import com.github.itadvc.jnsedb.JnsedbEmbeddedServer;
...
JnsedbEmbeddedServer dbServer = new JnsedbEmbeddedServer(dbDir);
// log all stored entities
dbServer.getConfiguration().setLogStoresEnabled(true);
// use cache replacement policy LFU (default is MRU, another possibility is LRU)
dbServer.getConfiguration().setCacheReplacementPolicy(CacheReplacementPolicy.LeastFrequentlyUsed);
// disable cache (annotation @Cache is ignored)
dbServer.getConfiguration().disableCache();
- Simple to use
- Fast
- Persistable
- Embeddable
- Index is cached in memory
- Loaded objects can be cached in memory
- Serialization using jackson, jackson annotations are allowed (@JsonInclude, @JsonProperty etc)
- Issue Tracker: github.com/itadvc/jnsedb/issues
- Source Code: github.com/itadvc/jnsedb
- Tests: junit
This project is released under the Apache license. See the bundled LICENSE file for details.
Krzysztof Andrzejczak