52 std::chrono::seconds
ttl{300};
77 std::vector<std::uint8_t>
data;
240 template <typename Predicate>
242 return cache_.invalidate_if(std::move(pred));
270 [[nodiscard]]
bool empty()
const;
288 [[nodiscard]]
double hit_rate() const noexcept;
310 [[nodiscard]] static std::
string build_key(
312 const std::vector<std::pair<std::
string, std::
string>>& params);
325 const std::
string& calling_ae,
327 const std::vector<std::pair<std::
string, std::
string>>& params);
DICOM query result cache with monitoring integration.
std::optional< cached_query_result > get(const key_type &key)
Retrieve a cached query result.
static std::string build_key(const std::string &query_level, const std::vector< std::pair< std::string, std::string > > ¶ms)
Build a cache key from query parameters.
size_type invalidate_if(Predicate pred)
void reset_stats() noexcept
Reset cache statistics.
string_lru_cache< cached_query_result > cache_
bool empty() const
Check if the cache is empty.
size_type size() const
Get the current number of cached entries.
void clear()
Remove all entries from the cache.
double hit_rate() const noexcept
Get the cache hit rate.
size_type max_size() const noexcept
Get the maximum cache size.
query_cache_config config_
const cache_stats & stats() const noexcept
Get cache statistics.
bool invalidate(const key_type &key)
Remove a specific entry from the cache.
size_type purge_expired()
Remove all expired entries.
query_cache & operator=(const query_cache &)=delete
query_cache(const query_cache &)=delete
Non-copyable.
void put(const key_type &key, const cached_query_result &result)
Store a query result in the cache.
static std::string build_key_with_ae(const std::string &calling_ae, const std::string &query_level, const std::vector< std::pair< std::string, std::string > > ¶ms)
Build a cache key with AE title prefix.
size_type invalidate_by_prefix(const std::string &prefix)
query_cache(const query_cache_config &config=query_cache_config{})
Construct a query cache with the given configuration.
size_type invalidate_by_query_level(const std::string &query_level)
Remove all entries for a specific query level.
query_cache(query_cache &&) noexcept=default
Movable.
Thread-safe LRU cache with TTL support.
query_cache & global_query_cache()
Get the global query cache instance.
bool configure_global_cache(const query_cache_config &config)
Configure the global query cache.
query_level
DICOM Query/Retrieve level enumeration.
Thread-safe LRU (Least Recently Used) cache for query results.
Statistics for cache performance monitoring.
Wrapper for cached query results.
std::vector< std::uint8_t > data
Serialized query result data.
std::string query_level
Query level (PATIENT, STUDY, SERIES, IMAGE)
std::chrono::steady_clock::time_point cached_at
Timestamp when this result was cached.
std::uint32_t match_count
Number of matching records in this result.
Configuration for the query cache.
bool enable_logging
Enable debug logging for cache operations.
std::size_t max_entries
Maximum number of cached query results.
bool enable_metrics
Enable metrics reporting to pacs_metrics.
std::chrono::seconds ttl
Time-to-live for cached results (default: 5 minutes)
std::string cache_name
Cache identifier for logging and metrics.