Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Berkeley DB Store

A compact Java key/value store backed by Oracle Berkeley DB Java Edition. It provides a small UTF-8 and binary API while retaining Berkeley DB's durable, transactional storage engine.

Features

  • Persistent string keys with string or binary values
  • Atomic overwrite and put-if-absent operations
  • Key existence checks and deletion
  • Configurable environment folder and logical database name
  • Customizable environment lifecycle through dependency injection
  • Thread-safe Berkeley DB access and deterministic resource cleanup
  • Java 8-compatible API with try-with-resources support

Requirements

  • JDK 8 or newer
  • Maven 3.6 or newer

Build

mvn clean verify

The compiled JAR is written to target/berkeley-db-1.0.jar.

Usage

import org.exoplatform.berkeley.BerkeleyStore;

try (BerkeleyStore store = new BerkeleyStore("data/customers", "customer-cache")) {
  store.put("customer:42:name", "Ada Lovelace");
  store.put("customer:42:avatar", avatarBytes);

  String name = store.get("customer:42:name");
  byte[] avatar = store.getBytes("customer:42:avatar");

  boolean created = store.putIfAbsent(
      "customer:42:status",
      "active");
  boolean removed = store.delete("customer:42:avatar");
}

The no-argument constructor stores data in ./db under the logical database name berkeley. For application-specific durability, caching, or database settings, subclass BerkeleyEnvironment and pass it to the injectable BerkeleyStore constructor.

Error handling

Operations throw BerkeleyException for invalid input, closed-store access, and Berkeley DB failures. Store construction fails immediately when its environment cannot be opened, so callers never receive a partially initialized instance.

License

GNU Affero General Public License v3.0 or later, matching the source headers.

About

Berkeley DB Java Edition is a open source, transactional storage solution for Java applications. The Direct Persistence Layer (DPL) API is faster and easier to develop, deploy, and manage than serialized object files or ORM-based Java persistence solutions

Resources

Stars

16 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages