https://github.com/9elt/junkdb
A trivial database to store script states
https://github.com/9elt/junkdb
database scripting
Last synced: about 2 months ago
JSON representation
A trivial database to store script states
- Host: GitHub
- URL: https://github.com/9elt/junkdb
- Owner: 9elt
- License: mit
- Created: 2024-03-03T10:17:32.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-31T21:37:07.000Z (over 1 year ago)
- Last Synced: 2025-03-03T12:34:13.839Z (over 1 year ago)
- Topics: database, scripting
- Language: C
- Homepage:
- Size: 61.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Junk DB
A trivial database to store script states
When using the default [*configuration*](./src/config.h), a junk database has a ***8KB* fixed size**, storing a **single numeric status** and *1009* **hashes of generic data**.
The latter cannot be read back, but only added, removed or checked for existence. **Older entries are overwritten** when the database limit is exceeded. Databases are **automatically created** on first access.
## Installation
#### Linux
```
$ git clone https://github.com/9elt/junkdb
$ cd junkdb
$ sh install.sh
```
This will locally install `junkdb`, `junkdb-cli` and set up your `data` directory.
## Protocol
```
```
#### Actions
`GET` Get the database *status*
`SET` Set the database *status*, the *payload* must be an integer
`HAS` Check if the database contains the *payload*
`ADD` Add the *payload* to the database
`REM` Remove the *payload* from the database
`DEL` Delete the database
#### Example
```
my-databse SET 32
```
## Client
#### Usage
```
junkdb-cli [options] [options]
junkdb-cli [options] --raw [options]
```
#### Options
| option | short | description |
|-----------|-------|---------------------------------------------|
| --strip | -s | strip response status |
| --raw | | execute raw request |
| --get | -G | get the database status |
| --set | -S | set the database status |
| --has | -H | check if the database contains the payload |
| --add | -A | add the payload to the database |
| --remove | -R | remove the payload from the database |
| --delete | -D | delete the datbase |
| --help | -h | show this help message |
| --version | -V | show junkdb-cli version |
#### Example
```
$ junkdb-cli 'my-database' --set 32
OK
```
```
$ junkdb-cli 'my-database' --get
OK 32
```
```
$ junkdb-cli 'my-database' --has 'Hello World!'
OK false
```
```
$ junkdb-cli 'my-database' --add 'Hello World!'
OK
```
```
$ junkdb-cli 'my-database' --has 'Hello World!'
OK true
```
```
$ junkdb-cli 'my-database' --remove 'Hello World!'
OK
```
```
$ junkdb-cli 'my-database' --delete
OK
```
```
$ junkdb-cli 'my-database SET 32' --raw
OK
```