hyperbee
hyperbee copied to clipboard
Derive node and key cache from shared rache
Depends on https://github.com/holepunchto/hypercore/pull/535 for it to really make sense
This makes the node- and key cache derive from the same rache.
It removes the maxCacheSize
opt, which is made redundant (technically a breaking change, but very recently added, and passing it in anyway won't cause any issues).
Note: this PR changes the ready flow (the caches can now only be set after this.core
is ready). Using the caches before the bee is ready doesn't make sense, so that should be fine.
The flow when a globalCache
is set on the underlying Hypercore
makes sense: all caches along all sessions then derive from the same globalCache
.
But when no globalCache
was set on the hypercore, each checkout/session will still create its own separate caches. This doesn't really make sense. It could be solved by passing a globalCache
object through when creating a new session. I didn't do that for now, because in the end it's the same behaviour as before (and the main focus of this PR is on the case where a globalCache
is used).