Allow tuning cache timeout

This allows users to tune cache timeout in Django.

Change-Id: I18cf8d80074203c044e69609dd7f713f6a2a593d
This commit is contained in:
Takashi Kajinami
2023-04-07 14:27:06 +09:00
parent 2180f17d01
commit c7229c6176
4 changed files with 14 additions and 0 deletions

View File

@@ -35,6 +35,10 @@
# (optional) A hash of parameters to enable specific cache options.
# Defaults to undef
#
# [*cache_timeout*]
# (optional) The default timeout, in seconds, to use for the cache.
# Defaults to undef
#
# [*cache_server_url*]
# (optional) URL of a cache server.
# This allows arbitrary strings to be set as CACHE BACKEND LOCATION.
@@ -567,6 +571,7 @@ class horizon(
$package_ensure = 'present',
$cache_backend = 'django.core.cache.backends.locmem.LocMemCache',
$cache_options = undef,
$cache_timeout = undef,
$cache_server_url = undef,
$cache_server_ip = undef,
$cache_server_port = '11211',

View File

@@ -0,0 +1,4 @@
---
features:
- |
The new ``horizon::cache_timeout`` parameter has been added.

View File

@@ -99,6 +99,7 @@ describe 'horizon' do
before do
params.merge!({
:cache_backend => 'django.core.cache.backends.memcached.MemcachedCache',
:cache_timeout => 300,
:cache_options => {'SOCKET_TIMEOUT' => 1,'SERVER_RETRIES' => 1,'DEAD_RETRY' => 1},
:cache_server_ip => '10.0.0.1',
:django_session_engine => 'django.contrib.sessions.backends.cache',
@@ -166,6 +167,7 @@ describe 'horizon' do
" 'SOCKET_TIMEOUT': 1,",
" 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',",
" 'LOCATION': '10.0.0.1:11211',",
" 'TIMEOUT': 300,",
'SESSION_ENGINE = "django.contrib.sessions.backends.cache"',
'OPENSTACK_KEYSTONE_URL = "https://keystone.example.com:4682"',
'OPENSTACK_KEYSTONE_DEFAULT_ROLE = "SwiftOperator"',

View File

@@ -240,6 +240,9 @@ CACHES = {
'LOCATION': '<%= @cache_server_url %>',
<%- end -%>
<%- end -%>
<%- if @cache_timeout -%>
'TIMEOUT': <%= @cache_timeout %>,
<%- end -%>
}
}