Coder Social home page Coder Social logo

cowdb's Introduction

CowDB - Pure Key/Value database for Erlang Applications

Copyright (c) 2014-2015 Benoit Chesneau and the contributors.

Version: 0.4.2

Authors: Benoit Chesneau ([email protected]).

Description

CowDB implements an indexed, key/value storage engine.

Features

  • Append-Only b-tree using COW
  • Read/Write can happen independently
  • Put/Get/Delete/Fold operations support transactions (add, remove operations on a 1 ore more store at once) transaction functions: Transaction functions can atomically analyze and transform database values in a transaction. You can use them to ensure atomic read-modify-update processing, and integrity constraints.
  • Transaction log
  • Snapshots support: you are able to take a snapshot of the database at any time (until the database is compacted)
  • Destructive compaction to reclaim space in your database. The log history is lost during the transaction.
  • Automatic compaction

Usage

Look at the cowdb module for the API usage.

main CowDB website is http://cowdb.org

Build process

1. Install rebar

To build CowDB you need to install rebar in your PATH. Rebar is available on Github:

https://github.com/rebar/rebar

Follow the README to install it.

2. Build the sources

Fetch the source code:

    $ git clone https://github.com/refuge/cowdb.git

Build the source, run the make command. It will fetch all required dependencies.

    $ cd /<PATH_TO>/cowdb
    $ make

3. Run tests

    $ make test

Example of usage:

    1> {ok, Pid} = cowdb:open("testing.db").
    {ok,<0.35.0>}
    2> cowdb:put(Pid, a, 1).
    {ok, 1}
    3> cowdb:get(Pid, a).
    {ok,{a,1}}
    4> cowdb:mget(Pid, [a, b]).
    [{ok,{a,1}},not_found]
    5> cowdb:put(Pid, b, 2).
    {ok, 2}
    6> cowdb:mget(Pid, [a, b]).
    [{ok,{a,1}},{ok,{b,2}}]
    7> cowdb:mget(Pid, [a, b, c, d]).
    [{ok,{a,1}},{ok,{b,2}},not_found,not_found]
    8> cowdb:transact(Pid, [
        {add, c, 2},
        {remove, b},
        {fn, fun(Db) ->
                    {ok, {a, V}} = cowdb:get(Db, a),
                    [{add, d, V}] end}]).
    {ok, 3}
    9> cowdb:mget(Pid, [a, b, c, d]).
    [{ok,{a,1}},not_found,{ok,{c,2}},{ok,{d,1}}]
    10> cowdb:fold(Pid, fun(Got, Acc) -> {ok, [Got | Acc]} end, []).
    {ok,[{d,1},{c,2},{a,1}]}

Ownership and License

The contributors are listed in AUTHORS. This project uses the MPL v2 license, see LICENSE.

cowdb uses the C4.1 (Collective Code Construction Contract) process for contributions.

Development

Under C4.1 process, you are more than welcome to help us by:

  • join the discussion over anything from design to code style try out
  • and submit issue reports
  • or feature requests pick a task in
  • issues and get it done fork
  • the repository and have your own fixes send us pull requests and even
  • star this project ^_^

To run the test suite:

    $ make test

Modules

Modules

cowdb
cowdb_util

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.