Module db

Source
Expand description

Low-level database operations. Not a public API. Locking is basically untested and probably flaky. Use at your own risk.

StructsΒ§

TableConnection
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_session to 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).