From d3f984eae544496340b53877bf35f96482cff233 Mon Sep 17 00:00:00 2001 From: Julien Malard Date: Tue, 24 Aug 2021 10:09:39 -0400 Subject: [PATCH] Create cache-opened-orbit-dbs.md --- scps/cache-opened-orbit-dbs.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 scps/cache-opened-orbit-dbs.md diff --git a/scps/cache-opened-orbit-dbs.md b/scps/cache-opened-orbit-dbs.md new file mode 100644 index 0000000..6d48874 --- /dev/null +++ b/scps/cache-opened-orbit-dbs.md @@ -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?