Description

A Leveldb implementation for D., Fixes for Comparator

Package Information

Version~master (2015-Apr-16)
Homepagehttps://github.com/dgallion1/d-leveldb
Repositoryhttps://github.com/dgallion1/d-leveldb
LicenseBSL-1.0
CopyrightCopyright © 2014, Byron Heads
AuthorsByron Heads, Darrell Gallion
Registered byDarrell Gallion
Dependencies

leveldb

Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Readme

#D-Leveldb Build Status A Leveldb implementation for D. Requires leveldb deimos bindings.

Forked, to fix the use of custom comparators.

##Comparator

class ComparatorDbKey: Options.Comparator
{
  override int compare(const char[] a, const char[] b) inout
  {
    immutable DbKey al = *cast(const DbKey*)a;
    immutable DbKey bl = *cast(const DbKey*)b;

    auto dTime   =  cast(int)(al.gTime - bl.gTime);
    return dTime;
  }
}

##Example

import leveldb, std.stdio;

void main()
{
    auto opt = new Options;
    opt.create_if_missing = true;

    auto db = new DB(opt, "path_to_my_db_folder");
    db.put("Hello", "World");

    assert(db.get_slice("Hello").as!string == "World");

    db.put("PI", 3.14);

    foreach(Slice key, Slice value; db)
    {
        if(key.as!string == "PI")
            writeln(key.as!string, ": ", value.as!double);
        else
            writeln(key.as!string, ": ", value.as!string);
    }
}

##Leveldb Version: 1.16.0

Installation

Get this with dub.

To use this package, put the following dependency into your project's package.json into the dependencies section:

{
        ...
        "dependencies": {
                "d-leveldb": "~master"
        }
}

Available versions

~master