支持缓存校验。

This commit is contained in:
zhengchao
2018-10-25 18:45:33 +08:00
parent 990e247155
commit 27d4581d9b
7 changed files with 523 additions and 211 deletions

View File

@@ -7,8 +7,9 @@ enum cache_query_status
{
WEB_CACHE_BEFORE_QUERY=0,
WEB_CACHE_NOT_APPLICABLE,
WEB_CACHE_QUERING,
WEB_CACHE_NOT_HIT,
WEB_CACHE_NEED_VERIFY,
WEB_CACHE_QUERY_DATA,
WEB_CACHE_MISS,
WEB_CACHE_HIT
};
struct cache_handle;
@@ -17,13 +18,16 @@ struct cached_meta
{
size_t content_length;
char* content_type;
char* last_modified;
char* etag;
};
struct cached_meta* cache_query_result_get_header(future_result_t * result);
void cache_query_free_meta(struct cached_meta* meta);
const struct cached_meta* cache_query_result_read_meta(future_result_t * result);
size_t cache_query_result_get_data(future_result_t * result, const unsigned char** pp_data);
enum cache_query_status async_web_cache_query(struct cache_handle* handle, unsigned int thread_id,
const struct tfe_http_half * request, struct future* f);
int web_cache_async_query(struct cache_handle* handle, unsigned int thread_id,
const struct tfe_http_half * request, struct future* f);
enum cache_query_result_type
{
CACHE_QUERY_RESULT_MISS,
@@ -35,6 +39,19 @@ enum cache_query_result_type
};
enum cache_query_result_type cache_query_result_get_type(future_result_t * result);
enum cache_pending_result
{
PENDING_RESULT_NONE=0,
PENDING_RESULT_FOBIDDEN,
PENDING_RESULT_REVALIDATE,
PENDING_RESULT_ALLOWED,
PENDING_RESULT_MISS
};
const struct cached_meta* cache_pending_result_read_meta(future_result_t * result);
enum cache_pending_result web_cache_async_pending(struct cache_handle* handle, unsigned int thread_id,
const struct tfe_http_half * request, struct future* f_revalidate);
struct cache_update_context;