ngx_int_t ngx_http_tfs_dedup_get(ngx_http_tfs_dedup_ctx_t *ctx, ngx_pool_t *pool, ngx_log_t * log) { u_char *p; ssize_t data_len; ngx_int_t rc; ngx_http_tair_data_t tair_key; data_len = 0; rc = ngx_http_tfs_sum_md5(ctx->file_data, ctx->tair_key, &data_len, log); if (rc == NGX_ERROR) { return NGX_ERROR; } p = ctx->tair_key; p += NGX_HTTP_TFS_MD5_RESULT_LEN; *(uint32_t *) p = htonl(data_len); tair_key.type = NGX_HTTP_TAIR_BYTEARRAY; tair_key.data = ctx->tair_key; tair_key.len = NGX_HTTP_TFS_DUPLICATE_KEY_SIZE; ctx->md5_sumed = 1; rc = ngx_http_tfs_tair_get_helper(ctx->tair_instance, pool, log, &tair_key, ngx_http_tfs_dedup_get_handler, ctx); return rc; }
ngx_int_t ngx_http_tfs_remote_block_cache_lookup( ngx_http_tfs_remote_block_cache_ctx_t *ctx, ngx_pool_t *pool, ngx_log_t *log, ngx_http_tfs_block_cache_key_t* key) { ngx_int_t rc; ngx_http_tair_data_t tair_key; ngx_log_debug2(NGX_LOG_DEBUG_HTTP, log, 0, "lookup remote block cache, ns addr: %uL, block id: %uD", key->ns_addr, key->block_id); tair_key.type = NGX_HTTP_TAIR_INT; tair_key.data = (u_char *)key; tair_key.len = NGX_HTTP_TFS_BLOCK_CACHE_KEY_SIZE; rc = ngx_http_tfs_tair_get_helper( ctx->tair_instance, pool, log, &tair_key, ngx_http_tfs_remote_block_cache_get_handler, (void *)ctx); return rc; }