Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create cache-opened-orbit-dbs.md #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions scps/cache-opened-orbit-dbs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Currently, orbit-db caches opened stores in `this.stores[address]` but it does not seem to use this cache when the same DB is requested again.
This can lead to situations where two parts of the code request the same DB and receive instead two unique open instances of the DB that did not sync correctly with each other.

I would propose to:
* Modify orbit-db so that cached dbs from this.stores are returned if available, **before** trying to reopen a db.
* Use Semaphore (or similar) to avoid concurrency problems in async code.

[This](https://github.com/phillmac/orbit-db-managers/blob/develop/src/DBManager.js) implementation of a cache by [phillmac](https://github.com/phillmac) seems much more sophisticated than what I proposed above.
Perhaps we can discuss more on which approach to use?