LevelDB JNI
openkk
13年前
<p>LevelDB JNI 提供了 Google 高效的Key/Value数据库 LevelDB 的 Java 接口。</p> <p>示例代码:</p> <pre class="brush:java; toolbar: true; auto-links: false;">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"));</pre> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1322745346077" target="_blank">http://www.open-open.com/lib/view/home/1322745346077</a></p> <p></p>