diff --git a/frameworks/js/napi/http/cache/lru_cache/src/lru_cache_disk_handler.cpp b/frameworks/js/napi/http/cache/lru_cache/src/lru_cache_disk_handler.cpp index c096d0d67ae04df2cfaf8ba465753357cb1f8602..ad4b97af83047f34e704120705cdc5138e76bb90 100644 --- a/frameworks/js/napi/http/cache/lru_cache/src/lru_cache_disk_handler.cpp +++ b/frameworks/js/napi/http/cache/lru_cache/src/lru_cache_disk_handler.cpp @@ -19,12 +19,13 @@ #include "lru_cache_disk_handler.h" -static constexpr const int WRITE_INTERVAL = 5 * 1000; +// static constexpr const int WRITE_INTERVAL = 5 * 1000; namespace OHOS::NetStack { LRUCacheDiskHandler::LRUCacheDiskHandler(std::string fileName, size_t capacity) : diskHandler_(std::move(fileName)), capacity_(std::min(MAX_DISK_CACHE_SIZE, capacity)) { +#if HTTP_CAHCE_ENABLE // 从磁盘中读取缓存到内存里 ReadCacheFromJsonFile(); // 起线程每一分钟讲内存缓存持久化 @@ -34,6 +35,7 @@ LRUCacheDiskHandler::LRUCacheDiskHandler(std::string fileName, size_t capacity) WriteCacheToJsonFile(); } }).detach(); +#endif } Json::Value LRUCacheDiskHandler::ReadJsonValueFromFile() diff --git a/frameworks/js/napi/http/http_exec/src/http_exec.cpp b/frameworks/js/napi/http/http_exec/src/http_exec.cpp index e437723bfc62db57b8da319d8d4617546710d982..b5adfb134c2aee4e655a688ed2190e48eb06dc54 100644 --- a/frameworks/js/napi/http/http_exec/src/http_exec.cpp +++ b/frameworks/js/napi/http/http_exec/src/http_exec.cpp @@ -67,11 +67,6 @@ bool HttpExec::initialized_ = false; bool HttpExec::ExecRequest(RequestContext *context) { - CacheProxy proxy(context->options); - if (proxy.ReadResponseFromCache(context->response)) { - return true; - } - if (!initialized_) { NETSTACK_LOGE("curl not init"); return false; @@ -120,10 +115,6 @@ bool HttpExec::ExecRequest(RequestContext *context) context->response.SetResponseCode(responseCode); context->response.ParseHeaders(); - if (context->response.GetResponseCode() == static_cast(ResponseCode::OK)) { - NETSTACK_LOGI("response code is 200, we write it to cache"); - proxy.WriteResponseToCache(context->response); - } return true; }