|
PACS System 0.1.0
PACS DICOM system library
|
DICOM query result cache with monitoring integration. More...
#include <query_cache.h>

Public Types | |
| using | key_type = std::string |
| using | value_type = cached_query_result |
| using | size_type = std::size_t |
Public Member Functions | |
| query_cache (const query_cache_config &config=query_cache_config{}) | |
| Construct a query cache with the given configuration. | |
| query_cache (const query_cache &)=delete | |
| Non-copyable. | |
| query_cache & | operator= (const query_cache &)=delete |
| query_cache (query_cache &&) noexcept=default | |
| Movable. | |
| query_cache & | operator= (query_cache &&) noexcept=default |
| ~query_cache ()=default | |
| std::optional< cached_query_result > | get (const key_type &key) |
| Retrieve a cached query result. | |
| void | put (const key_type &key, const cached_query_result &result) |
| Store a query result in the cache. | |
| void | put (const key_type &key, cached_query_result &&result) |
| Store a query result in the cache (move semantics) | |
| bool | invalidate (const key_type &key) |
| Remove a specific entry from the cache. | |
| size_type | invalidate_by_prefix (const std::string &prefix) |
| size_type | invalidate_by_query_level (const std::string &query_level) |
| Remove all entries for a specific query level. | |
| template<typename Predicate > | |
| size_type | invalidate_if (Predicate pred) |
| void | clear () |
| Remove all entries from the cache. | |
| size_type | purge_expired () |
| Remove all expired entries. | |
| size_type | size () const |
| Get the current number of cached entries. | |
| bool | empty () const |
| Check if the cache is empty. | |
| size_type | max_size () const noexcept |
| Get the maximum cache size. | |
| const cache_stats & | stats () const noexcept |
| Get cache statistics. | |
| double | hit_rate () const noexcept |
| Get the cache hit rate. | |
| void | reset_stats () noexcept |
| Reset cache statistics. | |
Static Public Member Functions | |
| 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. | |
| 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. | |
Private Attributes | |
| query_cache_config | config_ |
| string_lru_cache< cached_query_result > | cache_ |
DICOM query result cache with monitoring integration.
This class provides a specialized cache for C-FIND query results with:
Thread Safety: All public methods are thread-safe.
Definition at line 132 of file query_cache.h.
| using kcenon::pacs::services::cache::query_cache::key_type = std::string |
Definition at line 134 of file query_cache.h.
| using kcenon::pacs::services::cache::query_cache::size_type = std::size_t |
Definition at line 136 of file query_cache.h.
Definition at line 135 of file query_cache.h.
|
explicit |
Construct a query cache with the given configuration.
| config | Cache configuration |
Definition at line 22 of file query_cache.cpp.
|
delete |
Non-copyable.
|
defaultnoexcept |
Movable.
|
default |
|
staticnodiscard |
Build a cache key from query parameters.
Creates a deterministic key from the query level and parameters. The key format is: "level:param1=value1;param2=value2;..." Parameters are sorted by name for consistent key generation.
| query_level | The query retrieve level (PATIENT, STUDY, SERIES, IMAGE) |
| params | List of parameter name-value pairs |
Definition at line 110 of file query_cache.cpp.
References name.
Referenced by build_key_with_ae().

|
staticnodiscard |
Build a cache key with AE title prefix.
Includes the calling AE title in the key to support per-client caching.
| calling_ae | The calling AE title |
| query_level | The query retrieve level |
| params | List of parameter name-value pairs |
Definition at line 134 of file query_cache.cpp.
References build_key().

| void kcenon::pacs::services::cache::query_cache::clear | ( | ) |
Remove all entries from the cache.
Definition at line 78 of file query_cache.cpp.
References cache_.
|
nodiscard |
Check if the cache is empty.
Definition at line 90 of file query_cache.cpp.
References cache_.
|
nodiscard |
Retrieve a cached query result.
If found and not expired, the result is returned and the entry is marked as recently used. Cache metrics are updated.
| key | The cache key (use build_key to generate) |
Definition at line 31 of file query_cache.cpp.
References cache_.
|
nodiscardnoexcept |
Get the cache hit rate.
Definition at line 102 of file query_cache.cpp.
References cache_, and kcenon::pacs::services::cache::cache_stats::hit_rate().

| bool kcenon::pacs::services::cache::query_cache::invalidate | ( | const key_type & | key | ) |
Remove a specific entry from the cache.
| key | The cache key |
Definition at line 43 of file query_cache.cpp.
References cache_.
| query_cache::size_type kcenon::pacs::services::cache::query_cache::invalidate_by_prefix | ( | const std::string & | prefix | ) |
Definition at line 47 of file query_cache.cpp.
References cache_.
| query_cache::size_type kcenon::pacs::services::cache::query_cache::invalidate_by_query_level | ( | const std::string & | query_level | ) |
Remove all entries for a specific query level.
| query_level | The query level (PATIENT, STUDY, SERIES, IMAGE) |
Definition at line 55 of file query_cache.cpp.
References cache_.
|
inline |
Definition at line 241 of file query_cache.h.
References cache_.
|
nodiscardnoexcept |
Get the maximum cache size.
Definition at line 94 of file query_cache.cpp.
References cache_.
|
delete |
|
defaultnoexcept |
| query_cache::size_type kcenon::pacs::services::cache::query_cache::purge_expired | ( | ) |
Remove all expired entries.
Definition at line 82 of file query_cache.cpp.
References cache_.
| void kcenon::pacs::services::cache::query_cache::put | ( | const key_type & | key, |
| cached_query_result && | result ) |
Store a query result in the cache (move semantics)
| key | The cache key |
| result | The query result to cache (moved) |
Definition at line 39 of file query_cache.cpp.
References cache_.
| void kcenon::pacs::services::cache::query_cache::put | ( | const key_type & | key, |
| const cached_query_result & | result ) |
Store a query result in the cache.
| key | The cache key |
| result | The query result to cache |
Definition at line 35 of file query_cache.cpp.
References cache_.
|
noexcept |
|
nodiscard |
Get the current number of cached entries.
Definition at line 86 of file query_cache.cpp.
References cache_.
|
nodiscardnoexcept |
Get cache statistics.
Definition at line 98 of file query_cache.cpp.
References cache_.
|
private |
Definition at line 331 of file query_cache.h.
Referenced by clear(), empty(), get(), hit_rate(), invalidate(), invalidate_by_prefix(), invalidate_by_query_level(), invalidate_if(), max_size(), purge_expired(), put(), put(), reset_stats(), size(), and stats().
|
private |
Definition at line 330 of file query_cache.h.