Storage¶
Storage backends read and write table files. The default and only built-in
backend is JsonStorage, which stores each table as human-readable JSON.
Base¶
base
¶
Storage backend abstraction.
TinyStore talks to on-disk storage exclusively through :class:StorageBackend.
The query engine never performs filesystem operations. Today the only backend
is :class:~tinystore.storage.json.JsonStorage; the abstraction exists so that
alternative backends (e.g. a single-file or memory backend for tests) can be
plugged in later.
StorageBackend
¶
JSON backend¶
json
¶
JSON file storage backend.
Layout::
<root>/
metadata.json
tinystore.lock
journal/<txid>.json
tables/<name>.json
Each table is its own JSON file. Writes are atomic: data is serialized to a
temporary file in the same directory, flushed and fsync'd, then os.replace'd
into place, followed by a best-effort parent-directory fsync.