LevelDB JNIJava 接口
LevelDB JNI 提供了 Google 高效的Key/Value数据库 LevelDB 的 Java 接口。
示例代码:
import org.fusesource.leveldbjni.*; import static org.fusesource.leveldbjni.DB.*; import java.io.*;
Options options = new Options(); options.setCreateIfMissing(true); DB db = DB.open(options, new File("example")); try { // Use the db in here.... } finally { // Make sure you delete the db to shutdown the // database and avoid resource leaks. db.delete(); }
WriteOptions wo = new WriteOptions(); ReadOptions ro = new ReadOptions(); db.put(wo, bytes("Tampa"), bytes("rocks")); String value = asString(db.get(ro, bytes("Tampa"))); db.delete(wo, bytes("Tampa"));
评论