/* * Copyright (c) 2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include #include #include #include namespace RequestServer { class DiskCache { public: static ErrorOr create(); Optional create_entry(URL::URL const&, StringView method, u32 status_code, Optional reason_phrase, HTTP::HeaderMap const&, UnixDateTime request_time); Optional open_entry(URL::URL const&, StringView method); void clear_cache(); LexicalPath const& cache_directory() { return m_cache_directory; } void cache_entry_closed(Badge, CacheEntry const&); private: DiskCache(NonnullRefPtr, LexicalPath cache_directory, CacheIndex); NonnullRefPtr m_database; HashMap> m_open_cache_entries; LexicalPath m_cache_directory; CacheIndex m_index; }; }