allen-cell-animated / volume-viewer

https://allen-cell-animated.github.io/volume-viewer/
Other
90 stars 7 forks source link

Feature/Zarr loader caches chunks #149

Closed frasercl closed 10 months ago

frasercl commented 11 months ago

Changes the relationship between OMEZarrLoader and the cache: rather than caching whatever arbitrary subsets of the volume are requested, the loader caches the actual array chunks loaded by the underlying zarr library. This has some significant benefits:

I did this by writing a new Store, which is zarr.js's tiny abstraction around anything that can read and write data to a string path (the user's local storage, a server, etc.). ChunkCachingStore wraps any other store and adds cache queries and inserts. This approach is great in that it allows us to call regular zarr load methods without having to worry about the cache at all, but it also has some important implications:

One more thing: the loader now does its various metadata fetches on construction, rather than with every call to a loading method. This ought to save some unnecessary requests, but it did require replacing the constructor with an async static method.