Welcome! BergDB is a Java/.NET database designed to be simple and efficient. It was created for us developers who prefer to focus on our specific task, rather then spend time on database issues. BergDB has: simple key-value storage, ACID transactions, historic queries, efficient concurrency control, secondary indexes, fast append-only storage, replication, transparent object serialization and more. BergDB is an embedded, open-source, document-oriented, schemaless, NoSQL database.
The Java code below (C# code is nearly identical) creates a database
db1, gets a connection to it and stores the
object to it.
Database database = Factory.database().dir("db1").start(); Connection c = database.connection(); c.put("/adam", adam);
It is that simple :-) No query language, no annotations, no xml,
just what we love: simple, clean code.
BergDB transparently serializes the adam object for you.
Note that there is no need to close the connection.
So, you won't need to surround your beautiful code with some ugly
try-catch-finally. Assuming the
adam object is of type
it is read from the database like this:
adam = c.get("/adam", Person.class);
Now to a more advanced case; storing two objects in a single
transaction. Let's store
c.w().put("/adam", adam) .put("/eve", eve) .execute();
That's all there is to it. Adam and Eve will be always be stored together as one atomic unit.
BergDB is built from the ground up to execute transactions exceptionally fast. And there are no compromises, all writes to the database are made in ACID transactions with the highest possible level of consistency (in SQL-speak: serializable isolation level).
If you don't need to serialize objects, it is just as simple to store raw bytes and strings:
byte data = ... String text = ... c.put("/data", data); c.put("/text", text); byte data2 = c.get("/data", byte.class); String text2 = c.get("/text", String.class);
Unlike most databases, BergDB supports historic queries. Not only can the latest state be queried, but previous states can also be queried in exactly the same way. Here is an example:
Time t1 = c.getTime(); c.put("/key", "v1"); Time t2 = c.getTime(); c.put("/key", "v2"); c.setLookupTime(t1); c.get("/key", String.class); // returns "v1" c.setLookupTime(t2); c.get("/key", String.class); // returns "v2"
Historic queries are important when previous data states are of interest, and also as a fast way to handle concurrency. A read operation never locks anything in BergDB.
There is much to explore. I suggest you continue by browsing or downloading the latest release.