supercluster icon indicating copy to clipboard operation
supercluster copied to clipboard

Caching SuperCluster Index

Open melbinexperion opened this issue 1 year ago • 4 comments

Hi, is it possible to cache index generated by SuperCluster so that I can use it next time instead of calling new Supercluster({}).load() Again?

The code below takes time for large records. I am trying to get over this issue.

superclusterIndex = new Supercluster({ map: (props) => props, radius: MapConfig.clusterRadius, maxZoom: ClusterZoomLevel.maxZoom, }).load(geoJsonData.features);

melbinexperion avatar Mar 21 '23 12:03 melbinexperion

What do you mean by caching? You could simply save it into a singleton variable or whatever and use it as you need it.

Enkosz avatar Mar 28 '23 18:03 Enkosz

@Enkosz More like I wanted it to persist even after killing the app. So that I don't have to generate superClusterIndex again. The data I am handling is big like close to 70000 records. I was checking if I can save it in some storage so that each time user opens the app after killing, the indices generated are available.

melbinexperion avatar Mar 29 '23 10:03 melbinexperion

I'm wondering the same. My use case: running on servers behind a load balancer, with multiple sessions each clustering their own set of data. Each session is for a group of users that want to see the same clusters but may be hitting different servers. So I'm wondering if it's feasible to serialize the index and persist to a DB.

meta-meta avatar Nov 03 '23 19:11 meta-meta

@meta-meta @melbinexperion #134 explains how to serialize index

LeoMiguelB avatar May 22 '24 12:05 LeoMiguelB