BranchDB

Menu

Core Features

BranchDB is an in-memory key-value store built in C++, with support for TTL, set operations, authentication, and disk persistence. You can connect via a TCP client on port 1981 to start issuing commands.

Commands

Below is a quick overview of common BranchDB commands, what they do, and their syntax.

CommandSyntaxDescription
SETSET <key> <value> [EX <seconds>]Sets a key to hold a string value, with an optional Time-to-Live (TTL) in seconds.
GETGET <key>Retrieves the value of a key from the database.
DELDEL <key>Deletes a specified key from the database.
EXISTSEXISTS <key>Checks for the existence of a key in the database, returning a boolean value.
TTLTTL <key>Returns the remaining time to live (in seconds) for a key with an expiry set.
EXPIREEXPIRE <key> <seconds>Sets a new TTL for an existing key, overwriting any previous expiry.
PERSISTPERSIST <key>Removes the TTL from a key, making it permanent.
GETALLGETALLReturns all keys for the authenticated user's data partition.
FLUSHFLUSHDeletes all keys for the authenticated user and compacts the log file.

Time To Live

BranchDB allows you to store keys temporarily using TTL. You can attach an expiry time (in seconds) when setting a key. Once the time is up, the key vanishes — no manual deletion needed.

Terminal

> SET X 6 EX 10

> GET X

10

// After 10 Seconds

> GET X

Key Not found// Key 'X' Expired ( Deleted by Background Thread )