cachedb_init(struct module_env* env, int id)
{
	struct cachedb_env* cachedb_env = (struct cachedb_env*)calloc(1,
		sizeof(struct cachedb_env));
	if(!cachedb_env) {
		log_err("malloc failure");
		return 0;
	}
	env->modinfo[id] = (void*)cachedb_env;
	if(!cachedb_apply_cfg(cachedb_env, env->cfg)) {
		log_err("cachedb: could not apply configuration settings.");
		free(cachedb_env);
		env->modinfo[id] = NULL;
		return 0;
	}
	/* see if a backend is selected */
	if(!cachedb_env->backend || !cachedb_env->backend->name)
		return 1;
	if(!(*cachedb_env->backend->init)(env, cachedb_env)) {
		log_err("cachedb: could not init %s backend",
			cachedb_env->backend->name);
		free(cachedb_env);
		env->modinfo[id] = NULL;
		return 0;
	}
	cachedb_env->enabled = 1;
	if(env->cfg->serve_expired_reply_ttl)
		log_warn(
			"cachedb: serve-expired-reply-ttl is set but not working for data "
			"originating from the external cache; 0 TLL is used for those.");
	if(env->cfg->serve_expired_client_timeout)
		log_warn(
			"cachedb: serve-expired-client-timeout is set but not working for "
			"data originating from the external cache; expired data are used "
			"in the reply without first trying to refresh the data.");
	return 1;
}
cachedb_init(struct module_env* env, int id)
{
	struct cachedb_env* cachedb_env = (struct cachedb_env*)calloc(1,
		sizeof(struct cachedb_env));
	if(!cachedb_env) {
		log_err("malloc failure");
		return 0;
	}
	env->modinfo[id] = (void*)cachedb_env;
	if(!cachedb_apply_cfg(cachedb_env, env->cfg)) {
		log_err("cachedb: could not apply configuration settings.");
		free(cachedb_env);
		env->modinfo[id] = NULL;
		return 0;
	}
	 
	if(!cachedb_env->backend || !cachedb_env->backend->name)
		return 1;
	if(!(*cachedb_env->backend->init)(env, cachedb_env)) {
		log_err("cachedb: could not init %s backend",
			cachedb_env->backend->name);
		free(cachedb_env);
		env->modinfo[id] = NULL;
		return 0;
	}
	cachedb_env->enabled = 1;
	if(env->cfg->serve_expired_reply_ttl)
		log_warn(
			"cachedb: serve-expired-reply-ttl is set but not working for data "
			"originating from the external cache; 0 TLL is used for those.");
	if(env->cfg->serve_expired_client_timeout)
		log_warn(
			"cachedb: serve-expired-client-timeout is set but not working for "
			"data originating from the external cache; expired data are used "
			"in the reply without first trying to refresh the data.");
	return 1;
}