mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
feat(durable): IndexedDbStorage, a browser storage backed by IndexedDB (@earendil-works/pi-durable/storage/indexeddb)
This commit is contained in:
parent
bdd9f0399d
commit
16f5f0af4d
6 changed files with 1514 additions and 0 deletions
|
|
@ -759,10 +759,15 @@ const usage = await harness.usage(context); // { models: { "openai/gpt-6-sol": U
|
|||
| Backend | Import | Notes |
|
||||
|---|---|---|
|
||||
| Memory | `MemoryStorage` from the package root | Nothing is persisted. |
|
||||
| IndexedDB | `IndexedDbStorage.open(name)` from `@earendil-works/pi-durable/storage/indexeddb` | Browser-only storage in one IndexedDB database. |
|
||||
| SQLite | `openNodeSqliteStorage(file)` from `@earendil-works/pi-durable/storage/sqlite/node` | One database file. WAL mode with `synchronous = NORMAL`: commits survive process crashes; the newest may be lost on power or host failure. |
|
||||
| JSONL | `openNodeJsonlStorage(directory, context)` from `@earendil-works/pi-durable/storage/jsonl/node` | Append-only files in one directory. Pass `{ fsync: true }` to flush before each commit marker. Keeps the whole history in memory too, so memory grows with it; use SQLite for long-running agents. |
|
||||
| Cloudflare Durable Object | `openDurableObjectSqliteStorage(ctx.storage)` from `@earendil-works/pi-durable/storage/sqlite/cloudflare` | The SQLite storage of one SQLite-backed Durable Object; commits are its storage transactions. |
|
||||
|
||||
In a browser, open IndexedDB storage with `await IndexedDbStorage.open(name)`. One owner must hold the database at a
|
||||
time; use a [Web Lock](https://developer.mozilla.org/docs/Web/API/Web_Locks_API) around its lifetime rather than opening
|
||||
it in competing tabs or workers. Call `await navigator.storage.persist()` when durable retention matters.
|
||||
|
||||
SQLite storage can namespace its tables and indexes when sharing a database: pass `{ prefix: "pi_" }` to
|
||||
`SqliteStorage.open(database, options)`, `openNodeSqliteStorage(path, options)`, or
|
||||
`openDurableObjectSqliteStorage(ctx.storage, options)`. Storage renders the prefixed names into its SQL, so adapters
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue