支持promise finish。
This commit is contained in:
13
cache/src/tango_cache_redis.cpp
vendored
13
cache/src/tango_cache_redis.cpp
vendored
@@ -266,19 +266,19 @@ static void redis_hget_command_cb(struct redisAsyncContext *ac, void *vreply, vo
|
||||
{
|
||||
tango_cache_set_fail_state(ctx, CACHE_CACHE_MISS);
|
||||
ctx->get.result.type = RESULT_TYPE_MISS;
|
||||
promise_success(future_to_promise(ctx->future), &ctx->get.result);
|
||||
|
||||
promise_success(ctx->promise, &ctx->get.result);
|
||||
promise_finish(ctx->promise);
|
||||
}
|
||||
else
|
||||
{
|
||||
tango_cache_set_fail_state(ctx, CACHE_ERR_REDIS_JSON);
|
||||
if(reply!=NULL && reply->type==REDIS_REPLY_ERROR)
|
||||
{
|
||||
promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, reply->str);
|
||||
promise_failed(ctx->promise, FUTURE_ERROR_CANCEL, reply->str);
|
||||
}
|
||||
else
|
||||
{
|
||||
promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx));
|
||||
promise_failed(ctx->promise, FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx));
|
||||
}
|
||||
}
|
||||
tango_cache_ctx_destroy(ctx);
|
||||
@@ -290,7 +290,7 @@ static void redis_hget_command_cb(struct redisAsyncContext *ac, void *vreply, vo
|
||||
{
|
||||
case PARSE_JSON_RET_ERROR:
|
||||
tango_cache_set_fail_state(ctx, CACHE_ERR_REDIS_JSON);
|
||||
promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx));
|
||||
promise_failed(ctx->promise, FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx));
|
||||
tango_cache_ctx_destroy(ctx);
|
||||
break;
|
||||
case PARSE_JSON_RET_TIMEOUT:
|
||||
@@ -303,7 +303,8 @@ static void redis_hget_command_cb(struct redisAsyncContext *ac, void *vreply, vo
|
||||
case PARSE_JSON_RET_SUCC:
|
||||
fetch_header_over_biz(ctx);
|
||||
ctx->get.result.type = RESULT_TYPE_END;
|
||||
promise_success(future_to_promise(ctx->future), &ctx->get.result);
|
||||
promise_success(ctx->promise, &ctx->get.result);
|
||||
promise_finish(ctx->promise);
|
||||
tango_cache_ctx_destroy(ctx);
|
||||
break;
|
||||
default: assert(0);break;
|
||||
|
||||
Reference in New Issue
Block a user