修改FETCH API函数名为tango_cache_fetch_object;增加DELETE API;调整ctx结构体内部结构;

This commit is contained in:
zhangchengwei
2018-09-27 15:04:56 +08:00
committed by zhengchao
parent dc6a6331d3
commit ce3e46b6cf
11 changed files with 364 additions and 255 deletions

View File

@@ -17,6 +17,7 @@ enum CACHE_REQUEST_METHOD
{
CACHE_REQUEST_GET=0,
CACHE_REQUEST_PUT,
CACHE_REQUEST_DELETE,
};
enum GET_OBJECT_STATE
@@ -54,7 +55,6 @@ struct tango_cache_instance
time_t relative_ttl; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>
u_int64_t cache_limit_size;
long max_cnn_host;
u_int32_t block_len; //<2F><><EFBFBD><EFBFBD>buffercache<68>ڴ<EFBFBD><DAB4>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>ÿ<EFBFBD><C3BF>update<74><65><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD>ò<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
u_int32_t upload_block_size; //minio<69>ֶ<EFBFBD><D6B6>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>
enum CACHE_ERR_CODE error_code;
u_int32_t hash_object_key;
@@ -67,6 +67,30 @@ struct multipart_etag_list
TAILQ_ENTRY(multipart_etag_list) node;
};
struct cache_ctx_data_get
{
time_t max_age;//Get
time_t min_fresh;//Get
time_t expires;
time_t last_modify;
u_int32_t need_hdrs;
enum GET_OBJECT_STATE state;
struct easy_string response_tag;
};
struct cache_ctx_data_put
{
struct evbuffer *evbuf;
size_t upload_length;
size_t upload_offset;
char *uploadID;
char *combine_xml;
TAILQ_HEAD(__etag_list_head, multipart_etag_list) etag_head;
enum PUT_OBJECT_STATE state;
u_int32_t part_index; //<2F><>RESPONSE_HDR_
bool close_state; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ùر<C3B9>
};
struct tango_cache_ctx
{
CURL *curl;
@@ -74,34 +98,18 @@ struct tango_cache_ctx
struct future* future;
char error[CURL_ERROR_SIZE];
char object_key[256];
char hostport[24]; //<2F><>ͬctxʹ<78><CAB9><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>IP<49><50><EFBFBD><EFBFBD>֤pipeline˳<65><CBB3><EFBFBD><EFBFBD>
enum CACHE_REQUEST_METHOD method;
enum CACHE_ERR_CODE error_code;
struct evbuffer *evbuffer;
union{
enum PUT_OBJECT_STATE put_state;
enum GET_OBJECT_STATE get_state;
};
u_int32_t part_index;
u_int32_t need_hdrs; //<2F><>RESPONSE_HDR_
bool fail_state;
bool close_state; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ùر<C3B9>
long res_code;
time_t max_age;//Get
time_t min_fresh;//Get
time_t expires;
time_t last_modify;
size_t upload_length;
size_t upload_offset;
char *uploadID;
char *combine_xml;
struct easy_string response;
struct easy_string response_tag;
TAILQ_HEAD(__etag_list_head, multipart_etag_list) cache_head;
bool fail_state;
long res_code;
union{
struct cache_ctx_data_put put;
struct cache_ctx_data_get get;
};
struct tango_cache_instance *instance;
};
@@ -111,13 +119,13 @@ struct curl_socket_data
};
void easy_string_savedata(struct easy_string *estr, const char *data, size_t len);
void easy_string_expand(struct easy_string *estr, size_t to_size);
void easy_string_destroy(struct easy_string *estr);
void tango_cache_ctx_destroy(struct tango_cache_ctx *ctx);
struct tango_cache_ctx *tango_cache_update_prepare(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta);
struct tango_cache_ctx *tango_cache_fetch_prepare(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta);
struct tango_cache_ctx *tango_cache_delete_prepare(struct tango_cache_instance *instance, struct future* future, const char *objkey);
#endif