https://github.com/92181/hashdb
A tiny one dimensional database, written in plain C.
https://github.com/92181/hashdb
c cpp database hashmap xxhash
Last synced: 6 months ago
JSON representation
A tiny one dimensional database, written in plain C.
- Host: GitHub
- URL: https://github.com/92181/hashdb
- Owner: 92181
- License: mit
- Created: 2024-09-06T22:03:20.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-18T19:52:08.000Z (9 months ago)
- Last Synced: 2025-07-19T00:20:56.516Z (9 months ago)
- Topics: c, cpp, database, hashmap, xxhash
- Language: C
- Homepage:
- Size: 43 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tiny Key-Value Database
A tiny key-value store database written in plain C, I decided to write this to understand the inner-workings of databases further and familiarize myself with different hashing algoritms such as SHA256 and xxHash.
The library is consists of a single C header file which can be easily included in any C or C++ project.
This hash based 'database' is thus fully embeddable and modular. Various use cases are shown such as...
* Basic usage example, insert, retrieve and delete entries with their respondings keys.
* A disk write mode (MMAP), which allows you to store memory pages on the disk.
* Database context switching, between multiple active DB's.
# Usage
This is a basic example on how to use the small library correctly.
```c
// Create Context;
hdb j;dbc(&j,128,1024);
// Insert Key And Corresponding Value;
dbi(&j,"Math","The hashmap.",5,12);
// Remove The Entry By The Supplied Key;
dbd("Math",5);
// Retrieve Values Stored In Array By Key;
char *y,*r;y=dbg(&j,"Math",5,&r);ptr(y,r);
// Destroy Context;
dis(&j);
```
# License & Attribution
It uses an custom implemention of the xxHash hashing algorithm created by Yann Collet (BSD 2-Clause License).
This project uses the MIT Attribution license. If you like this project consider starring it.
Made By Wolf Pieter Schulz.