<directivesynopsis>
<name>MemcacheConnTTL</name>
<description>Keepalive time for idle connections</description>
-<syntax>MemcacheConnTTL <em>seconds</em></syntax>
-<default>MemcacheConnTTL 15</default>
+<syntax>MemcacheConnTTL <em>num[units]</em></syntax>
+<default>MemcacheConnTTL 15s</default>
<contextlist>
<context>server config</context>
<context>virtual host</context>
</contextlist>
+<compatibility>Available in Apache 2.4.17 and later</compatibility>
<usage>
- <p>Set the time, in seconds, to keep idle connections with the memcache
- server(s) alive (threaded platforms only).</p>
+ <p>Set the time to keep idle connections with the memcache server(s)
+ alive (threaded platforms only).</p>
- <p>Valid values for <directive>MemcacheConnTTL</directive> are integers
- from 1 to 1800. That is to say, up to half an hour.</p>
+ <p>Valid values for <directive>MemcacheConnTTL</directive> are times
+ up to one hour. 0 means no timeout.</p>
+
+ <note><p>This timeout defaults to units of seconds, but accepts
+ suffixes for milliseconds (ms), seconds (s), minutes (min), and hours (h).
+ </p></note>
+
+ <p>Before Apache 2.4.17, this timeout was hardcoded and its value was 600 usec.
+ So, the closest configuration to match the legacy behaviour is to set
+ <directive>MemcacheConnTTL</directive> to 1ms.</p>
+
+ <example>
+ <highlight language="config">
+# Set a timeout of 10 minutes
+MemcacheConnTTL 10min
+# Set a timeout of 60 seconds
+MemcacheConnTTL 60
+ </highlight>
+ </example>
</usage>
</directivesynopsis>
#endif
#ifndef MC_DEFAULT_SERVER_TTL
-#define MC_DEFAULT_SERVER_TTL (15*1000*1000) /* 15 seconds */
+#define MC_DEFAULT_SERVER_TTL apr_time_from_sec(15)
#endif
module AP_MODULE_DECLARE_DATA socache_memcache_module;
typedef struct {
- unsigned int ttl;
+ apr_uint32_t ttl;
} socache_mc_svr_cfg;
struct ap_socache_instance_t {
static const char *socache_mc_set_ttl(cmd_parms *cmd, void *dummy,
const char *arg)
{
+ apr_interval_time_t ttl;
socache_mc_svr_cfg *sconf = ap_get_module_config(cmd->server->module_config,
&socache_memcache_module);
- int i;
- i = atoi(arg);
+ if (ap_timeout_parameter_parse(arg, &ttl, "s") != APR_SUCCESS) {
+ return apr_pstrcat(cmd->pool, cmd->cmd->name,
+ " has wrong format", NULL);
+ }
- if ((i < 1) || (i > 1800)) {
+ if ((ttl < apr_time_from_sec(0)) || (ttl > apr_time_from_sec(3600))) {
return apr_pstrcat(cmd->pool, cmd->cmd->name,
- " must be a number between 1 and 1800.", NULL);
+ " can only be 0 or up to one hour.", NULL);
}
/* apr_memcache_server_create needs a ttl in usec. */
- sconf->ttl = i * 1000 * 1000;
+ sconf->ttl = ttl;
return NULL;
}
static const command_rec socache_memcache_cmds[] = {
AP_INIT_TAKE1("MemcacheConnTTL", socache_mc_set_ttl, NULL, RSRC_CONF,
- "TTL used for the connection with the memcache server(s), in seconds"),
+ "TTL used for the connection with the memcache server(s)"),
{ NULL }
};