Add cache parameter 'selects'
This commit is contained in:
parent
987a52b398
commit
6db3cc380b
@ -227,6 +227,29 @@ cached_data=thread_specific
|
||||
Default is `shared`. See `max_count` and `max_size` what implication changing
|
||||
this setting to `thread_specific` has.
|
||||
|
||||
#### `selects`
|
||||
|
||||
An enumeration option specifying what approach the cache should take with
|
||||
respect to `SELECT` statements. The allowed values are:
|
||||
|
||||
* `assume_cacheable`: The cache can assume that all `SELECT` statements,
|
||||
without exceptions, are cacheable.
|
||||
* `verify_cacheable`: The cache can *not* assume that all `SELECT`
|
||||
statements are cacheable, but must verify that.
|
||||
|
||||
```
|
||||
select=assume_cacheable
|
||||
```
|
||||
|
||||
Default is `verify_cacheable`. In this case, the `SELECT` statements will be
|
||||
parsed and only those that are safe for caching - e.g. do *not* call any
|
||||
non-cacheable functions or access any non-cacheable variables - will be
|
||||
subject to caching.
|
||||
|
||||
If `assume_cacheable` is specified, then all `SELECT` statements are
|
||||
assumed to be cacheable and will be parsed *only* if some specific rule
|
||||
requires that.
|
||||
|
||||
#### `debug`
|
||||
|
||||
An integer value, using which the level of debug logging made by the cache
|
||||
|
26
server/modules/filter/cache/cachefilter.cc
vendored
26
server/modules/filter/cache/cachefilter.cc
vendored
@ -49,6 +49,8 @@ void cache_config_finish(CACHE_CONFIG& config)
|
||||
config.hard_ttl = 0;
|
||||
config.soft_ttl = 0;
|
||||
config.debug = 0;
|
||||
config.thread_model = CACHE_THREAD_MODEL_MT;
|
||||
config.selects = CACHE_SELECTS_VERIFY_CACHEABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,13 +109,21 @@ bool cache_command_show(const MODULECMD_ARG* pArgs)
|
||||
//
|
||||
|
||||
// Enumeration values for `cached_data`
|
||||
static const MXS_ENUM_VALUE cached_data_values[] =
|
||||
static const MXS_ENUM_VALUE parameter_cached_data_values[] =
|
||||
{
|
||||
{"shared", CACHE_THREAD_MODEL_MT},
|
||||
{"thread_specific", CACHE_THREAD_MODEL_ST},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
// Enumeration values for `selects`
|
||||
static const MXS_ENUM_VALUE parameter_selects_values[] =
|
||||
{
|
||||
{"assume_cacheable", CACHE_SELECTS_ASSUME_CACHEABLE},
|
||||
{"verify_cacheable", CACHE_SELECTS_VERIFY_CACHEABLE},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
static modulecmd_arg_type_t show_argv[] =
|
||||
@ -194,7 +204,14 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||
MXS_MODULE_PARAM_ENUM,
|
||||
CACHE_DEFAULT_THREAD_MODEL,
|
||||
MXS_MODULE_OPT_NONE,
|
||||
cached_data_values
|
||||
parameter_cached_data_values
|
||||
},
|
||||
{
|
||||
"selects",
|
||||
MXS_MODULE_PARAM_ENUM,
|
||||
CACHE_DEFAULT_SELECTS,
|
||||
MXS_MODULE_OPT_NONE,
|
||||
parameter_selects_values
|
||||
},
|
||||
{MXS_END_MODULE_PARAMS}
|
||||
}
|
||||
@ -291,7 +308,10 @@ bool CacheFilter::process_params(char **pzOptions, MXS_CONFIG_PARAMETER *ppParam
|
||||
config.max_resultset_size = config_get_size(ppParams, "max_resultset_size");
|
||||
config.thread_model = static_cast<cache_thread_model_t>(config_get_enum(ppParams,
|
||||
"cached_data",
|
||||
cached_data_values));
|
||||
parameter_cached_data_values));
|
||||
config.selects = static_cast<cache_selects_t>(config_get_enum(ppParams,
|
||||
"selects",
|
||||
parameter_selects_values));
|
||||
|
||||
if (!config.storage)
|
||||
{
|
||||
|
9
server/modules/filter/cache/cachefilter.h
vendored
9
server/modules/filter/cache/cachefilter.h
vendored
@ -54,6 +54,14 @@
|
||||
#define CACHE_DEFAULT_MAX_SIZE "0"
|
||||
// Thread model
|
||||
#define CACHE_DEFAULT_THREAD_MODEL "shared"
|
||||
// Cacheable selects
|
||||
#define CACHE_DEFAULT_SELECTS "verify_cacheable"
|
||||
|
||||
typedef enum cache_selects
|
||||
{
|
||||
CACHE_SELECTS_ASSUME_CACHEABLE,
|
||||
CACHE_SELECTS_VERIFY_CACHEABLE,
|
||||
} cache_selects_t;
|
||||
|
||||
typedef struct cache_config
|
||||
{
|
||||
@ -70,4 +78,5 @@ typedef struct cache_config
|
||||
uint64_t max_size; /**< Maximum size of the cache.*/
|
||||
uint32_t debug; /**< Debug settings. */
|
||||
cache_thread_model_t thread_model; /**< Thread model. */
|
||||
cache_selects_t selects; /**< Assume/verify that selects are cacheable. */
|
||||
} CACHE_CONFIG;
|
||||
|
Loading…
x
Reference in New Issue
Block a user