Files
pdf/engine/include/pdfengine/ocr_cache.hpp
T

27 lines
570 B
C++
Raw Normal View History

2026-08-01 16:19:11 +05:30
#pragma once
#include <pdfengine/ocr_types.hpp>
#include <unordered_map>
#include <mutex>
#include <optional>
#include <string>
namespace pdfengine {
class OCRCache {
public:
static OCRCache& instance();
void put(const std::string& imageHash, const OCRPage& ocrPage);
[[nodiscard]] std::optional<OCRPage> get(const std::string& imageHash) const;
void clear();
[[nodiscard]] size_t size() const;
private:
OCRCache() = default;
mutable std::mutex m_mutex;
std::unordered_map<std::string, OCRPage> m_cache;
};
} // namespace pdfengine