radare2/shlr/sdb
2017-11-03 10:27:18 +08:00
..
memcache Minor fix for sdb sync 2013-07-16 17:48:26 +02:00
msvc Added sdb/msvc to sdb-sync 2017-08-28 14:04:56 +02:00
src Renaming char_to_w32 => utf8_to_utf16 2017-11-03 10:27:18 +08:00
test Minor fix for sdb sync 2013-07-16 17:48:26 +02:00
config.mk Convert char to windows unicode 2017-11-03 10:27:18 +08:00
Jamroot Remove configure-plugins dependency for the make meson 2017-05-26 02:43:53 +02:00
Makefile Fix crash in tk -!!!! d'B%CCCC!9!!!!_ 2017-09-30 18:34:19 +02:00
meson.build Update sdb from git 2017-08-26 02:26:16 +02:00
README.md Bump sdb to fix hash collision issues 2017-01-14 22:02:33 +01:00

SDB (string database)

sdb is a simple string key/value database based on djb's cdb disk storage and supports JSON and arrays introspection.

mcsdbd is a memcache server with disk storage based on sdb. It is distributed as a standalone binary and a library.

There's also the sdbtypes: a vala library that implements several data structures on top of an sdb or a memcache instance.

Travis

Build Status

Build Status

Author

pancake pancake@nopcode.org

Contains

  • namespaces (multiple sdb paths)
  • atomic database sync (never corrupted)
  • bindings for vala, luvit, newlisp and nodejs
  • commandline frontend for sdb databases
  • memcache client and server with sdb backend
  • arrays support (syntax sugar)
  • json parser/getter (js0n.c)

Rips

  • disk storage based on cdb code
  • linked lists from r2 api

Compilation

For native builds just type make. Everything will be compiled twice to get the .dylib and .a and sdb in PIC and nonPIC modes.

To compile with Emscripten for Javascript:

make CC=emcc EXT_EXE=.js

Changes

I have modified cdb code a little to create smaller databases and be memory leak free in order to use it from a library.

The sdb's cdb database format is 10% smaller than the original one. This is because keylen and valuelen are encoded in 4 bytes: 1 for the key length and 3 for the value length.

In a test case, a 4.3MB cdb database takes only 3.9MB after this file format change.

Usage example

Let's create a database!

$ sdb d hello=world
$ sdb d hello
world

Using arrays (>=0.6):

$ sdb - '[]list=1,2' '[0]list' '[0]list=foo' '[]list' '[+1]list=bar'
1
foo
2

Let's play with json:

$ sdb d g='{"foo":1,"bar":{"cow":3}}'
$ sdb d g:bar.cow
3
$ sdb - user='{"id":123}' user:id=99 user:id
99

Using the commandline without any disk database:

$ sdb - foo=bar foo a=3 +a -a
bar
4
3

$ sdb -
foo=bar
foo
bar
a=3
+a
4
-a
3

Remove the database

$ rm -f d