util/disk_cache.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include <cstdint> | ||
| 5 | #include <filesystem> | ||
| 6 | #include <optional> | ||
| 7 | #include <string> | ||
| 8 | #include <string_view> | ||
| 9 | #include <utility> | ||
| 10 | |||
| 11 | namespace chrono::batch_render { | ||
| 12 | |||
| 13 | 3549 | class DiskCache { | |
| 14 | public: | ||
| 15 | 2334 | explicit DiskCache(std::filesystem::path directory) : m_directory(std::move(directory)) {} | |
| 16 | |||
| 17 | std::optional<std::string> Load(std::string_view key) const; | ||
| 18 | |||
| 19 | void Store(std::string_view key, std::string_view bytes) const; | ||
| 20 | |||
| 21 | private: | ||
| 22 | std::filesystem::path Path(std::string_view key) const; | ||
| 23 | |||
| 24 | std::filesystem::path m_directory; | ||
| 25 | }; | ||
| 26 | |||
| 27 | std::filesystem::path UserCacheDirectory(); | ||
| 28 | |||
| 29 | std::filesystem::path KernelCacheDirectory(const std::filesystem::path& root); | ||
| 30 | |||
| 31 | void TrimKernelCache(const std::filesystem::path& root, uint64_t limit); | ||
| 32 | |||
| 33 | } | ||
| 34 |