diff --git a/cache/include/tango_cache_client.h b/cache/include/tango_cache_client.h index a0eda49..109c258 100644 --- a/cache/include/tango_cache_client.h +++ b/cache/include/tango_cache_client.h @@ -79,7 +79,7 @@ enum CACHE_HTTP_HDR_TYPE struct tango_cache_meta_get { - const char* url; //缓存:URL;非结构化日志:文件名;最大长度256字节 + const char* url; //缓存:URL;非结构化日志:文件名;CACHE_OBJECT_KEY_HASH_SWITCH=0时最大长度256字节,=1时无限制 struct request_freshness get; }; diff --git a/cache/src/tango_cache_client.cpp b/cache/src/tango_cache_client.cpp index 5a05e9a..394a7af 100644 --- a/cache/src/tango_cache_client.cpp +++ b/cache/src/tango_cache_client.cpp @@ -40,15 +40,18 @@ void caculate_sha256(const char *data, unsigned long len, char *result, u_int32_ { SHA256_CTX c; unsigned char sha256[128]; + u_int32_t length; SHA256_Init(&c); SHA256_Update(&c, data, len); SHA256_Final(sha256, &c); - - for(u_int32_t i=0; i<32 && i 64)?32:(size-1)/2; //预留一个空间 + for(u_int32_t i=0; istatistic.memory_used >= instance->cache_limit_size) @@ -319,6 +322,9 @@ struct tango_cache_ctx *tango_cache_update_prepare(struct tango_cache_instance * { caculate_sha256(meta->url, strlen(meta->url), buffer, 72); snprintf(ctx->object_key, 256, "%c%c/%c%c/%s", buffer[0], buffer[1], buffer[2], buffer[3], buffer+4); + //保存原始URL + snprintf(buffer, 2064, "x-amz-meta-url: %s", meta->url); + ctx->headers = curl_slist_append(ctx->headers, buffer); } else { @@ -428,7 +434,7 @@ int tango_cache_upload_once_evbuf(struct tango_cache_instance *instance, struct struct tango_cache_ctx *tango_cache_fetch_prepare(struct tango_cache_instance *instance, struct future* f, struct tango_cache_meta_get *meta) { struct tango_cache_ctx *ctx; - char sha256[72]={0}; + char sha256[72]; ctx = (struct tango_cache_ctx *)calloc(1, sizeof(struct tango_cache_ctx)); ctx->instance = instance; @@ -472,7 +478,7 @@ int tango_cache_fetch_object(struct tango_cache_instance *instance, struct futur struct tango_cache_ctx *tango_cache_delete_prepare(struct tango_cache_instance *instance, struct future* f, const char *objkey) { struct tango_cache_ctx *ctx; - char sha256[72]={0}; + char sha256[72]; ctx = (struct tango_cache_ctx *)calloc(1, sizeof(struct tango_cache_ctx)); ctx->instance = instance;