修改cache-client依赖hiredis(修改版)的CMakeList.txt,编译通过。

This commit is contained in:
zhengchao
2018-10-25 20:40:10 +08:00
parent 27d4581d9b
commit 96feddefb8
10 changed files with 51 additions and 763 deletions

View File

@@ -26,7 +26,7 @@ enum cache_stat_field
STAT_CACHE_QUERY_ERR,
STAT_CACHE_QUERY_ABANDON,
STAT_CACHE_QUERYING,
STAT_CACHE_META_QUERYING,
STAT_CACHE_PENDING,
STAT_CACHE_UPLOAD_CNT,
STAT_CACHE_UPLOAD_OVERRIDE,
STAT_CACHE_UPLOAD_FORBIDEN,
@@ -161,6 +161,7 @@ void cache_stat_init(struct cache_handle* cache)
set_stat_spec(&spec[STAT_CACHE_QUERY_ERR], "get_err",FS_STYLE_STATUS, FS_CALC_CURRENT);
set_stat_spec(&spec[STAT_CACHE_QUERY_ABANDON], "get_abandon",FS_STYLE_STATUS, FS_CALC_CURRENT);
set_stat_spec(&spec[STAT_CACHE_QUERYING], "getting",FS_STYLE_STATUS, FS_CALC_CURRENT);
set_stat_spec(&spec[STAT_CACHE_PENDING], "pending",FS_STYLE_STATUS, FS_CALC_CURRENT);
set_stat_spec(&spec[STAT_CACHE_UPLOAD_CNT], "cache_put",FS_STYLE_FIELD, FS_CALC_CURRENT);
set_stat_spec(&spec[STAT_CACHE_UPLOAD_OVERRIDE], "or_put",FS_STYLE_FIELD, FS_CALC_CURRENT);
set_stat_spec(&spec[STAT_CACHE_UPLOAD_FORBIDEN], "put_forbid",FS_STYLE_FIELD, FS_CALC_CURRENT);
@@ -229,7 +230,7 @@ struct cache_handle* create_web_cache_handle(const char* profile_path, const cha
}
MESA_load_profile_int_def(profile_path, section, "get_concurrency_max", &temp, 1000*1000);
cache->put_concurrency_max=temp;
cache->get_concurrency_max=temp;
MESA_load_profile_int_def(profile_path, section, "put_concurrency_max", &(temp), 1000*1000);
cache->put_concurrency_max=temp;
MESA_load_profile_int_def(profile_path, section, "query_undefined_obj", &(cache->query_undefined_obj_enabled), 1);
@@ -452,10 +453,10 @@ static void cache_query_meta_on_succ(future_result_t * result, void * user)
//NOT break intentionally.
case RESULT_TYPE_END:
//last call.
ATOMIC_DEC(&(ctx->ref_handle->stat_val[STAT_CACHE_META_QUERYING]));
ATOMIC_DEC(&(ctx->ref_handle->stat_val[STAT_CACHE_PENDING]));
promise_dettach_ctx(p);
promise_success(p, ctx);
cache_query_ctx_free_cb(ctx);
cache_pending_ctx_free_cb(ctx);
break;
default:
break;
@@ -467,8 +468,8 @@ static void cache_query_meta_on_fail(enum e_future_error err, const char * what,
struct promise * p = (struct promise *) user;
struct cache_pending_context* ctx=(struct cache_pending_context*)promise_dettach_ctx(p);
promise_failed(p, err, what);
ATOMIC_DEC(&(ctx->ref_handle->stat_val[STAT_CACHE_META_QUERYING]));
cache_query_ctx_free_cb(ctx);
ATOMIC_DEC(&(ctx->ref_handle->stat_val[STAT_CACHE_PENDING]));
cache_pending_ctx_free_cb(ctx);
return;
}
@@ -525,7 +526,7 @@ enum cache_pending_result web_cache_async_pending(struct cache_handle* handle, u
ctx->req_if_none_match=tfe_strdup(tfe_http_std_field_read(request, TFE_HTTP_IF_NONE_MATCH));
promise_set_ctx(p, ctx, cache_pending_ctx_free_cb);
ATOMIC_INC(&(handle->stat_val[STAT_CACHE_META_QUERYING]));
ATOMIC_INC(&(handle->stat_val[STAT_CACHE_PENDING]));
ctx->f_tango_cache_fetch=future_create("_cache_meta", cache_query_meta_on_succ, cache_query_meta_on_fail, p);
int ret=tango_cache_head_object(handle->clients[thread_id], ctx->f_tango_cache_fetch, &meta);
assert(ret==0);
@@ -611,10 +612,10 @@ struct cache_update_context* web_cache_update_start(struct cache_handle* handle,
put_action=tfe_cache_put_pending(session->resp, &resp_freshness);
switch(put_action){
case FORBIDDEN:
case REVALIDATE:
ATOMIC_INC(&(handle->stat_val[STAT_CACHE_UPLOAD_FORBIDEN]));
TFE_LOG_DEBUG(handle->logger, "cache update forbiden: %s", session->req->req_spec.url);
return NULL;
return NULL;
case REVALIDATE:
case ALLOWED:
break;
case UNDEFINED:
@@ -654,20 +655,21 @@ struct cache_update_context* web_cache_update_start(struct cache_handle* handle,
meta.usertag=user_tag_str;
meta.usertag_len=strlen(user_tag_str)+1;
}
memcpy(&meta.put, &resp_freshness, sizeof(resp_freshness));
meta.put=resp_freshness;
struct wrap_cache_put_ctx* _cache_put_ctx=ALLOC(struct wrap_cache_put_ctx, 1);
_cache_put_ctx->url=tfe_strdup(session->req->req_spec.url);
_cache_put_ctx->start=time(NULL);
_cache_put_ctx->ref_handle=handle;
_cache_put_ctx->f=future_create("cache_put", wrap_cache_update_on_succ, wrap_cache_update_on_fail, _cache_put_ctx);
TFE_LOG_DEBUG(handle->logger, "cache update allowed: %s", _cache_put_ctx->url);
write_ctx=tango_cache_update_start(handle->clients[thread_id], _cache_put_ctx->f, &meta);
if(write_ctx==NULL)//exceed maximum cache memory size.
{
wrap_cache_put_ctx_free(_cache_put_ctx);
assert(0);
return NULL;
}
TFE_LOG_DEBUG(handle->logger, "cache upload allowed: %s", _cache_put_ctx->url);
if(is_undefined_obj)
{
ATOMIC_INC(&(handle->stat_val[STAT_CACHE_UPLOAD_OVERRIDE]));