Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

How to use flask_caching on functions in modules?

$
0
0

Hi, I have my main app main.py where all the Dash-specific code (layout, callbacks,…) is. I put everything not Dash-specific in a separate folder and import that as a module via import helpers. These are database calls and other slow computations that I want to memoize using the Flask Cache. But I am stuck:

I create the Cache object in main.py:

import dash
from flask_caching import Cache
import helpers
app = dash.Dash()
cache = Cache(app.server, config={
    'CACHE_TYPE': 'filesystem',
    'CACHE_DIR': 'cache'
    })
x = helpers.do_some_slow_computation(1,2,3)
...

But how can I share this object with the “helpers” module?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles