diff --git a/server/modules/filter/cache/cacheconfig.cc b/server/modules/filter/cache/cacheconfig.cc index db7eb3558..10aeb62f4 100644 --- a/server/modules/filter/cache/cacheconfig.cc +++ b/server/modules/filter/cache/cacheconfig.cc @@ -34,24 +34,24 @@ config::ParamString CacheConfig::s_storage_options( "\"\"" ); -config::ParamDuration CacheConfig::s_hard_ttl( +config::ParamDuration CacheConfig::s_hard_ttl( &s_specification, "hard_ttl", "Hard time to live; the maximum amount of time the cached result is " "used before it is discarded and the result is fetched from the backend. " "See also 'soft_ttl'.", mxs::config::INTERPRET_AS_SECONDS, - std::chrono::seconds { 0 } + std::chrono::milliseconds { 0 } ); -config::ParamDuration CacheConfig::s_soft_ttl( +config::ParamDuration CacheConfig::s_soft_ttl( &s_specification, "soft_ttl", "Soft time to live; the maximum amount of time the cached result is " "used before the first client querying for the result is used for refreshing " "the cached data from the backend. See also 'hard_ttl'.", mxs::config::INTERPRET_AS_SECONDS, - std::chrono::seconds { 0 } + std::chrono::milliseconds { 0 } ); config::ParamCount CacheConfig::s_max_resultset_rows( diff --git a/server/modules/filter/cache/cacheconfig.hh b/server/modules/filter/cache/cacheconfig.hh new file mode 100644 index 000000000..d606c894d --- /dev/null +++ b/server/modules/filter/cache/cacheconfig.hh @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2018 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl11. + * + * Change Date: 2022-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ +#pragma once + +#include +#include +#include "cache_storage_api.hh" + +typedef enum cache_selects +{ + CACHE_SELECTS_ASSUME_CACHEABLE, + CACHE_SELECTS_VERIFY_CACHEABLE, +} cache_selects_t; + +const cache_selects_t CACHE_DEFAULT_SELECTS = CACHE_SELECTS_ASSUME_CACHEABLE; + +typedef enum cache_in_trxs +{ + // Do NOT change the order. Code relies upon NEVER < READ_ONLY < ALL. + CACHE_IN_TRXS_NEVER, + CACHE_IN_TRXS_READ_ONLY, + CACHE_IN_TRXS_ALL, +} cache_in_trxs_t; + +const cache_thread_model CACHE_DEFAULT_THREAD_MODEL = CACHE_THREAD_MODEL_ST; + + +class CacheConfig : public config::Configuration +{ +public: + CacheConfig(); + ~CacheConfig(); + + CacheConfig(const CacheConfig&) = delete; + CacheConfig& operator = (const CacheConfig&) = delete; + + using milliseconds = std::chrono::milliseconds; + + config::String storage; + config::String storage_options; + config::Duration hard_ttl; + config::Duration soft_ttl; + config::Count max_resultset_rows; + config::Size max_resultset_size; + config::Count max_count; + config::Size max_size; + config::Path rules; + config::BitMask debug; + config::Enum thread_model; + config::Enum selects; + config::Enum cache_in_trxs; + config::Bool enabled; + char* zStorage_options { nullptr}; /**< Raw options for storage module. */ + char** storage_argv { nullptr }; /**< Cooked options for storage module. */ + int storage_argc { 0 }; /**< Number of cooked options. */ + + static const config::Specification& specification() + { + return s_specification; + } + +private: + bool configure() override; + +private: + static config::Specification s_specification; + + static config::ParamString s_storage; + static config::ParamString s_storage_options; + static config::ParamDuration s_hard_ttl; + static config::ParamDuration s_soft_ttl; + static config::ParamCount s_max_resultset_rows; + static config::ParamSize s_max_resultset_size; + static config::ParamCount s_max_count; + static config::ParamSize s_max_size; + static config::ParamPath s_rules; + static config::ParamBitMask s_debug; + static config::ParamEnum s_thread_model; + static config::ParamEnum s_selects; + static config::ParamEnum s_cache_in_trxs; + static config::ParamBool s_enabled; +};