MXS-1475 Add 'enabled' parameter to Cache filter
With 'enabled' it can be specified whether the cache should initially be enabled or disabled. Useful as it is now possible to enable/disable the cache dynamically.
This commit is contained in:
6
server/modules/filter/cache/cachefilter.cc
vendored
6
server/modules/filter/cache/cachefilter.cc
vendored
@ -243,6 +243,11 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
MXS_MODULE_OPT_NONE,
|
MXS_MODULE_OPT_NONE,
|
||||||
parameter_cache_in_trxs_values
|
parameter_cache_in_trxs_values
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"enabled",
|
||||||
|
MXS_MODULE_PARAM_BOOL,
|
||||||
|
CACHE_DEFAULT_ENABLED
|
||||||
|
},
|
||||||
{MXS_END_MODULE_PARAMS}
|
{MXS_END_MODULE_PARAMS}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -351,6 +356,7 @@ bool CacheFilter::process_params(char **pzOptions, MXS_CONFIG_PARAMETER *ppParam
|
|||||||
config.cache_in_trxs = static_cast<cache_in_trxs_t>(config_get_enum(ppParams,
|
config.cache_in_trxs = static_cast<cache_in_trxs_t>(config_get_enum(ppParams,
|
||||||
"cache_in_transactions",
|
"cache_in_transactions",
|
||||||
parameter_cache_in_trxs_values));
|
parameter_cache_in_trxs_values));
|
||||||
|
config.enabled = config_get_bool(ppParams, "enabled");
|
||||||
|
|
||||||
if (!config.storage)
|
if (!config.storage)
|
||||||
{
|
{
|
||||||
|
|||||||
3
server/modules/filter/cache/cachefilter.h
vendored
3
server/modules/filter/cache/cachefilter.h
vendored
@ -60,6 +60,8 @@
|
|||||||
#define CACHE_DEFAULT_STORAGE "storage_inmemory"
|
#define CACHE_DEFAULT_STORAGE "storage_inmemory"
|
||||||
// Transaction behaviour
|
// Transaction behaviour
|
||||||
#define CACHE_DEFAULT_CACHE_IN_TRXS "all_transactions"
|
#define CACHE_DEFAULT_CACHE_IN_TRXS "all_transactions"
|
||||||
|
// Enabled
|
||||||
|
#define CACHE_DEFAULT_ENABLED "true"
|
||||||
|
|
||||||
typedef enum cache_selects
|
typedef enum cache_selects
|
||||||
{
|
{
|
||||||
@ -92,4 +94,5 @@ typedef struct cache_config
|
|||||||
cache_thread_model_t thread_model; /**< Thread model. */
|
cache_thread_model_t thread_model; /**< Thread model. */
|
||||||
cache_selects_t selects; /**< Assume/verify that selects are cacheable. */
|
cache_selects_t selects; /**< Assume/verify that selects are cacheable. */
|
||||||
cache_in_trxs_t cache_in_trxs; /**< To cache or not to cache inside transactions. */
|
cache_in_trxs_t cache_in_trxs; /**< To cache or not to cache inside transactions. */
|
||||||
|
bool enabled; /**< Whether the cache is enabled or not. */
|
||||||
} CACHE_CONFIG;
|
} CACHE_CONFIG;
|
||||||
|
|||||||
@ -187,7 +187,7 @@ CacheFilterSession::CacheFilterSession(MXS_SESSION* pSession, Cache* pCache, cha
|
|||||||
, m_zUseDb(NULL)
|
, m_zUseDb(NULL)
|
||||||
, m_refreshing(false)
|
, m_refreshing(false)
|
||||||
, m_is_read_only(true)
|
, m_is_read_only(true)
|
||||||
, m_enabled(true) // TODO: Add configuration variable for initial mode.
|
, m_enabled(pCache->config().enabled)
|
||||||
, m_variable_added(false)
|
, m_variable_added(false)
|
||||||
{
|
{
|
||||||
m_key.data = 0;
|
m_key.data = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user