pycrdt-store provides persistent storage solutions for `pycrdt`, specifically offering a `SQLiteYStore` implementation. It enables `pycrdt` documents to persist their state beyond application lifetime, supporting features like history squashing, cleanup based on database size, and performance optimizations. The current version is 0.1.3, and the library is under active development with frequent minor releases addressing performance, features, and bug fixes.
pip install pycrdt-storeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up `SQLiteYStore` with a `pycrdt.YDoc` to enable persistent storage. It initializes an in-memory SQLite database, performs a simple text insertion, and then properly closes the store. For file-based persistence, replace `:memory:` with a file path like `./my_document.db`.
Review the `SQLiteYStore` constructor arguments for `cleanup_when_db_size_above`, `squash_history_older_than`, and `squash_no_more_often_than` to configure the automatic maintenance behavior.
Always ensure `await store.setup()` is called before using the store, and `await store.close()` is called when the store is no longer needed, typically at application shutdown.
Ensure that every `YDoc` instance using the same `SQLiteYStore` has a distinct `doc_name` string passed during its initialization: `YDoc(unique_doc_name, store)`.