http_cache.h 1022 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #pragma once
  2. #include "http_define.h"
  3. #include "http_reqpack.h"
  4. #include "http_interface.h"
  5. #include "yutil/map.hpp"
  6. namespace ylib
  7. {
  8. namespace network
  9. {
  10. namespace http
  11. {
  12. class cache :public network::http::interface_, public ylib::error_base
  13. {
  14. public:
  15. cache();
  16. ~cache();
  17. bool start(const ylib::json& config);
  18. void stop();
  19. bool have_send(network::http::reqpack* rp);
  20. bool enable();
  21. std::string make_key(const std::string& filepath);
  22. bool find_ext(const std::string& filepath);
  23. std::string make_cache_filepath(const std::string& filepath);
  24. private:
  25. bool m_enable;
  26. std::string m_filepath;
  27. std::vector<std::string> m_exts;
  28. timestamp m_timeout_min;
  29. ylib::map<std::string, std::string> m_keys;
  30. };
  31. }
  32. }
  33. }