将读取配置单独抽出形成parameter API;支持Redis多机备份和故障切换。
This commit is contained in:
15
cache/src/cache_evbase_client.cpp
vendored
15
cache/src/cache_evbase_client.cpp
vendored
@@ -168,7 +168,7 @@ static void cache_asyn_ioevent_dispatch(struct databuffer *buffer)
|
||||
break;
|
||||
case CACHE_ASYN_HEAD:
|
||||
f = ctx_asyn->ctx->future;
|
||||
if(ctx_asyn->instance_asyn->instance->head_meta_source == HEAD_META_FROM_REDIS)
|
||||
if(ctx_asyn->instance_asyn->instance->param->head_meta_source == HEAD_META_FROM_REDIS)
|
||||
{
|
||||
ret = tango_cache_head_redis(ctx_asyn->ctx);
|
||||
}
|
||||
@@ -395,7 +395,7 @@ int cache_evbase_upload_once_data(struct cache_evbase_instance *instance, struct
|
||||
}
|
||||
if(path != NULL)
|
||||
{
|
||||
snprintf(path, pathsize, "http://%s/%s/%s", ctx->hostaddr, instance->instance->bucketname, ctx->object_key);
|
||||
snprintf(path, pathsize, "http://%s/%s/%s", ctx->hostaddr, instance->instance->param->bucketname, ctx->object_key);
|
||||
}
|
||||
|
||||
ctx_asyn = (struct cache_evbase_ctx *)calloc(1, sizeof(struct cache_evbase_ctx));
|
||||
@@ -442,7 +442,7 @@ int cache_evbase_upload_once_evbuf(struct cache_evbase_instance *instance, struc
|
||||
}
|
||||
if(path != NULL)
|
||||
{
|
||||
snprintf(path, pathsize, "http://%s/%s/%s", ctx->hostaddr, instance->instance->bucketname, ctx->object_key);
|
||||
snprintf(path, pathsize, "http://%s/%s/%s", ctx->hostaddr, instance->instance->param->bucketname, ctx->object_key);
|
||||
}
|
||||
|
||||
ctx_asyn = (struct cache_evbase_ctx *)calloc(1, sizeof(struct cache_evbase_ctx));
|
||||
@@ -555,7 +555,12 @@ int cache_evbase_delete_object(struct cache_evbase_instance *instance, struct fu
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct cache_evbase_instance *cache_evbase_instance_new(const char* profile_path, const char* section, void *runtimelog)
|
||||
struct tango_cache_parameter *cache_evbase_parameter_new(const char* profile_path, const char* section, void *runtimelog)
|
||||
{
|
||||
return tango_cache_parameter_new(profile_path, section, runtimelog);
|
||||
}
|
||||
|
||||
struct cache_evbase_instance *cache_evbase_instance_new(struct tango_cache_parameter *param, void *runtimelog)
|
||||
{
|
||||
evutil_socket_t notification_fd[2];
|
||||
struct cache_evbase_instance *instance_asyn;
|
||||
@@ -576,7 +581,7 @@ struct cache_evbase_instance *cache_evbase_instance_new(const char* profile_path
|
||||
instance_asyn->evbase = evbase;
|
||||
instance_asyn->notify_readfd = notification_fd[0];
|
||||
instance_asyn->notify_sendfd = notification_fd[1];
|
||||
instance_asyn->instance = tango_cache_instance_new(evbase, profile_path, section, runtimelog);
|
||||
instance_asyn->instance = tango_cache_instance_new(param, evbase, runtimelog);
|
||||
if(instance_asyn->instance == NULL)
|
||||
{
|
||||
free(instance_asyn);
|
||||
|
||||
Reference in New Issue
Block a user