/* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/
/* Find all the servers in the first run to get a total count */
cache_config = apr_pstrdup(p, ctx->servers);
split = apr_strtok(cache_config, ",", &tok); while (split) {
nservers++;
split = apr_strtok(NULL,",", &tok);
}
rv = apr_memcache_create(p, nservers, 0, &ctx->mc); if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, APLOGNO(00785) "Failed to create Memcache Object of '%d' size.",
nservers); return rv;
}
/* Now add each server to the memcache */
cache_config = apr_pstrdup(p, ctx->servers);
split = apr_strtok(cache_config, ",", &tok); while (split) {
apr_memcache_server_t *st; char *host_str; char *scope_id;
apr_port_t port;
/* Converts (binary) id into a key prefixed by the predetermined * namespace tag; writes output to key buffer. Returns non-zero if
* the id won't fit in the key buffer. */ staticint socache_mc_id2key(ap_socache_instance_t *ctx, constunsignedchar *id, unsignedint idlen, char *key, apr_size_t keylen)
{ char *cp;
/* memcache needs time in seconds till expiry; fail if this is not
* positive *before* casting to unsigned (apr_uint32_t). */
expiry -= apr_time_now(); if (apr_time_sec(expiry) <= 0) { return APR_EINVAL;
}
rv = apr_memcache_set(ctx->mc, buf, (char*)ucaData, nData,
apr_time_sec(expiry), 0);
if (ap_timeout_parameter_parse(arg, &ttl, "s") != APR_SUCCESS) { return apr_pstrcat(cmd->pool, cmd->cmd->name, " has wrong format", NULL);
}
if ((ttl < apr_time_from_sec(0)) || (ttl > apr_time_from_sec(3600))) { return apr_pstrcat(cmd->pool, cmd->cmd->name, " can only be 0 or up to one hour.", NULL);
}
/* apr_memcache_server_create needs a ttl in usec. */
sconf->ttl = ttl;
staticconst 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)"),
{ NULL }
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.