emilhe / dash-extensions

The dash-extensions package is a collection of utility functions, syntax extensions, and Dash components that aim to improve the Dash development experience
https://www.dash-extensions.com/
MIT License
409 stars 57 forks source link

Specifying the use of the `key` variable for `Serverside` objects in the documentation #302

Closed matt-sd-watson closed 6 months ago

matt-sd-watson commented 6 months ago

I have created a Flask and dash app that uses dash components, including the ServersideOutputTransform, to cache and store large dictionaries of arrays. The component works very well for my requirements.

I recently discovered that specifying the same key string for Serverside objects in different callbacks allows the transform to overwrite the previous pickle files in the specified backend directory. Previously, without any unique key, the transform would create a new pickled object, and this would cause a lot of duplicate data writing to the temporary cache, as well as cause the temporary cache to become populated very quickly with many pickle files.

I would suggest explicitly explaining in the documentation how the key parameter for Serverside objects works, as this can save a great deal of disk space when Serverside objects are constantly being updated from different callbacks. Now, when using a unique key, I can drastically reduce the amount of disk space required for my Serverside objects in session.

emilhe commented 6 months ago

I have added the following paragraph to the docs to make this point more clear,

Keys

Per default, the Serverside object generates a (new) unique key for every callback invocation to ensure that data is never shared between invocations and/or sessions. However, if this is not a requirement, using a fixed key will reduce the data usage of the backend significantly, as only a single copy of the data will be stored (instead of one per callback invocation).