Cache

Bowtie provides a simple key value store where you can store data with the client. Keep in mind that if you store a large amount of data it will get transferred to and from the client which could result in a poor user experience. That being said, it can be very useful to store results from expensive computations.

class bowtie._cache._Cache[source]

Store data in the browser.

This cache uses session storage so data will stay in the browser until the tab is closed. All data must be serializable, which means if the serialization transforms the data it won’t be the same when it is fetched.

Examples

>>> from bowtie import cache
>>> cache['a'] = True  # doctest: +SKIP
>>> cache['a']  # doctest: +SKIP
True
>>> cache['b'] = np.arange(5)  # doctest: +SKIP
>>> cache['b']  # doctest: +SKIP
[1, 2, 3, 4, 5]