#include "future.h" struct tango_cache_instance{}; struct tango_cache_update_ctx{}; #define CACHE_FRAG_BEGIN 0x01 #define CACHE_FRAG_DATA 0x02 #define CACHE_FRAG_END 0x04 #define CACHE_FRAG_FULL (CACHE_FRAG_BEGIN|CACHE_FRAG_DATA|CACHE_FRAG_END) struct tango_cache_result { char frag_type; unsigned char* data_frag; size_t size; }; struct tango_cache_meta { const char* url; const char* content_type; }; struct tango_cache_instance* tango_cache_init(event_base* evbase,const char* profile_path, const char* section); int tango_cache_fetch(struct tango_cache_instance* instance,struct future* future, const char* http_hdr, const char* url); //following tfe_stream_write_xx functions are NOT thread safe, MUST be called in the stream process thread. struct tango_cache_update_ctx* tango_cache_update_start(struct tango_cache_instance* instance,struct future* future, const char* http_hdr, const char* url); /* @return 0 if successful, or -1 if an error occurred */ int tango_cache_update_frag(struct tango_cache_update_ctx* ctx,const unsigned char *data, size_t size); void tango_cache_update_end(struct tango_cache_update_ctx*ctx);