对象key开启hash时,在元信息中保存原始url
This commit is contained in:
2
cache/include/tango_cache_client.h
vendored
2
cache/include/tango_cache_client.h
vendored
@@ -79,7 +79,7 @@ enum CACHE_HTTP_HDR_TYPE
|
||||
|
||||
struct tango_cache_meta_get
|
||||
{
|
||||
const char* url; //<2F><><EFBFBD><EFBFBD>:URL<52><4C><EFBFBD>ǽṹ<C7BD><E1B9B9><EFBFBD><EFBFBD>־:<3A>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>256<EFBFBD>ֽ<EFBFBD>
|
||||
const char* url; //<2F><><EFBFBD><EFBFBD>:URL<52><4C><EFBFBD>ǽṹ<C7BD><E1B9B9><EFBFBD><EFBFBD>־:<3A>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>CACHE_OBJECT_KEY_HASH_SWITCH=0ʱ<30><CAB1><EFBFBD><EFBFBD>256<35>ֽڣ<D6BD>=1ʱ<31><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
struct request_freshness get;
|
||||
};
|
||||
|
||||
|
||||
16
cache/src/tango_cache_client.cpp
vendored
16
cache/src/tango_cache_client.cpp
vendored
@@ -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<size/2; i++)
|
||||
|
||||
length = (size > 64)?32:(size-1)/2; //Ԥ<><D4A4>һ<EFBFBD><D2BB><EFBFBD>ռ<EFBFBD>
|
||||
for(u_int32_t i=0; i<length; i++)
|
||||
{
|
||||
sprintf(result + i*2, "%02x", sha256[i]);
|
||||
}
|
||||
result[length*2] = '\0';
|
||||
}
|
||||
|
||||
static int wired_load_balancer_lookup(WLB_handle_t wiredlb, const char *key, int keylen, char *host, size_t hostsize)
|
||||
@@ -300,7 +303,7 @@ int tango_cache_update_frag_evbuf(struct tango_cache_ctx *ctx, enum EVBUFFER_COP
|
||||
struct tango_cache_ctx *tango_cache_update_prepare(struct tango_cache_instance *instance, struct future* f, struct tango_cache_meta_put *meta)
|
||||
{
|
||||
struct tango_cache_ctx *ctx;
|
||||
char buffer[256]={0};
|
||||
char buffer[2064];
|
||||
time_t expires, now, last_modify;
|
||||
|
||||
if((u_int64_t)instance->statistic.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);
|
||||
//<2F><><EFBFBD><EFBFBD>ԭʼ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;
|
||||
|
||||
Reference in New Issue
Block a user