Expand description
Low-level database operations. Not a public API. Locking is basically untested and probably flaky. Use at your own risk.
StructsΒ§
- Table
Connection - A connection to a specific table in a redb database.
EnumsΒ§
- DbKind π
- The kind of database we are opening. Wrapped is the default mode that we
will later extend with compression/encryption + buffered in-memory storage.
Unwrapped (
_u) is always a plain redb file with no extra wrapping.
ConstantsΒ§
- DB_
FILE_ πLOCK_ FAMILY - UNWRAPPED_
TABLES π
StaticsΒ§
- DB_POOL π
- Global, thread-safe pool of lazily-opened databases, keyed by (
DbKind, name). - LOCK_
SESSIONS π - NEXT_
LOCK_ πID
FunctionsΒ§
- db_
file_ πlock - db_path π
- db_pool π
- delete_
str_ u64 - Delete a u64 value by string key.
- delete_
u64_ bytes - Delete a byte slice by u64 key.
- delete_
u64_ str - Delete a string value by u64 key.
- get_
all_ u64_ keys - get_
or_ πopen_ database - Open or fetch from the pool a Database for the given name and kind.
- get_
str_ u64 - Get a u64 value by string key.
- get_
u64_ bytes - Get a byte vector by u64 key.
- get_
u64_ str - Get a string value by u64 key.
- lock_
database_ session - Convenience: lock a single database (redb file) and return a session id.
Use
unlock_databases_sessionto release. - lock_
databases_ session - Acquire locks for one or more databases and return an opaque session ID to hold those locks until explicitly released. This is suitable for use over an IPC boundary where a separate βdatabase processβ manages locks on behalf of clients.
- lock_
sessions π - new_
lock_ πid - open
- Open a thread-safe, but not multi-process-safe, connection to a specific table in a wrapped redb database.
- open_
redb_ πfile - Create or open a redb database file on disk (no wrapping).
- open_u
- Open a thread-safe, but not multi-process-safe, connection to a specific table in an unwrapped redb database.
- put_
str_ u64 - Put a u64 value by string key.
- put_
u64_ bytes - Put a byte slice by u64 key.
- put_
u64_ str - Put a string value by u64 key.
- unlock_
databases_ session - Release a previously created lock session by its session ID. All locks associated with the session are released (dropped).