Git Product home page Git Product logo

libsdb's Introduction

libsdb

Small key-value database library for embedded or lowmemory devices

OBJECT STATUS
Library Done. Only FILE engine is available.
Interface Done.
Documentation Partially done.
Default engine Not implemented.
File engine Done.
Tests Only integration tests for file engine.

API

DB API:

Method Explanation Prototype
insert add new record bool sdb_insert(sdb_dbo *db, const char *key, const char *value);
update update existing record bool sdb_update(sdb_dbo *db, const char *key, const char *value);
select select existing record const char *sdb_select(sdb_dbo *db, const char *key);
delete remove existing record bool sdb_delete(sdb_dbo *db, const char *key);
exist Check record existence by returing non-negative size ssize_t sdb_exist(sdb_dbo *db, const char *key);

Access&utility API:

Method Explanation Prototype
open or create database sdb_dbo *sdb_open(sdb_engine engine, void *params);
close database void sdb_close(sdb_dbo *db);
set buffer size for next database from sdb_open() call void sdb_tune(void *your_buffer, size_t your_buffer_size);
pass different your own memory management functions void sdb_configure(void *(*y_malloc)(size_t size), void *(*y_calloc)(size_t nmemb, size_t size), void (*y_free)(void *ptr), void *(*y_realloc)(void *ptr, size_t size));

Overview

libsdb is configurable key-value database libraray for your own applications. You need to perform 3 steps to start using it:

  1. Download & compile
  2. Include libsdb.h to your project
  3. Link your project with libsdb.so shared library

libsdb was made of view of KISS principle, portability, small memory usage. I'm planning (at this moment) to support 3 database engines:

  1. MYSQL
  2. Memory
  3. Files

Currently, only file engine is implemented. Maybe if someone (or me) needs more - I'll implement all of them.

At this moment you can configure:

  1. Memory management functions for whole library
  2. Buffer size for each database. (default buffer size is defined in libsdb.h)

Build

  1. Download this repository via git
  2. cd to downloaded directory
  3. execute "make" command

Getting started

Here is an example pseudocode to help you understand how easy you can use it.

...
#include <libsdb.h>

...

{
    ...

    sdb_dbo *db = sdb_open(SDB_FILENO, "my_storage");
    const char *result = sdb_select(db, "mycoolkey");

    ...

}

Contribution

Use github issues or pull requests for questions or contribution.

Notes

  1. You may need some kind of wrapper if you wish to use it on some different programming language then C.
  2. If you are able to compile & link with library, but can't start your program, make sure that copy of libsdb.so file is located in appropriate path. Or just configure LD_LIBRARY_PATH.

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.