Skip to content

Commit ed83aa7

Browse files
author
Mark Gibbs
committed
Added configuration parameter for initial arguments caching
1 parent 24c29e0 commit ed83aa7

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

django_plotly_dash/dash_wrapper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from .app_name import app_name, main_view_label
3939
from .middleware import EmbeddedHolder
4040

41+
4142
uid_counter = 0
4243

4344
usable_apps = {}

django_plotly_dash/templatetags/plotly_dash.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from django.core.cache import cache
3131

3232
from django_plotly_dash.models import DashApp
33-
from django_plotly_dash.util import pipe_ws_endpoint_name
33+
from django_plotly_dash.util import pipe_ws_endpoint_name, cache_timeout_initial_arguments
3434

3535
register = template.Library()
3636

@@ -76,7 +76,7 @@ def plotly_app(context, name=None, slug=None, da=None, ratio=0.1, use_frameborde
7676
# Generate a cache id
7777
cache_id = "dpd-initial-args-%s" % str(uuid.uuid4()).replace('-', '')
7878
# Store args in json form in cache
79-
cache.set(cache_id, initial_arguments, 60)
79+
cache.set(cache_id, initial_arguments, cache_timeout_initial_arguments())
8080
else:
8181
cache_id = None
8282

django_plotly_dash/util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,7 @@ def insert_demo_migrations():
5353
def http_poke_endpoint_enabled():
5454
'Return true if the http endpoint is enabled through the settings'
5555
return _get_settings().get('http_poke_enabled', True)
56+
57+
def cache_timeout_initial_arguments():
58+
'Return cache timeout, in seconds, for initial arguments'
59+
return _get_settings().get('cache_timeout_initial_arguments', 60)

docs/configuration.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ below.
2121
2222
# Insert data for the demo when migrating
2323
"insert_demo_migrations" : False,
24+
25+
# Timeout for caching of initial arguments in seconds
26+
"cache_timeout_initial_arguments": 60,
2427
}
2528
2629
Defaults are inserted for missing values. It is also permissible to not have any ``PLOTLY_DASH`` entry in

0 commit comments

Comments
 (0)