Skip to content

Tomo tiling: Use a LRU cache for the tiles

Thomas Vincent requested to merge tile-lru-cache into main

This MR makes use of a LRU cache for the cache of H5grovePyramidTilesApi

It does so by replacing the use of react-suspense-fetch (based on a map) by use-suspense-fetch (based on lru-cache). The LRU cache can be configured by passing lru-cache options to the H5grovePyramidTilesApi constructor. The default is 500 tiles max with max age 1h (see https://github.com/snakeUni/use-suspense-fetch/blob/b92f6830a10c5e0ffa646b805dc9341cc0ec4182/src/suspense.ts#L8-L12).

I had to add buffer as a dependency to avoid 🤷

Module not found: Error: Can't resolve 'buffer' in '/media/unused/tvincent/BM18-env/daiquiri-tomo/daiquiri-ui.git/node_modules/.pnpm/safe-buffer@5.2.1/node_modules/safe-buffer'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "buffer": require.resolve("buffer/") }'
	- install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "buffer": false }

attn @sfisher, for MR !517 (closed), here the store behavior is changed but the API is backward compatible, expect that now you can configure the LRU cache.

Merge request reports