6 #ifndef IROHA_ABSTRACT_CACHE_HPP 7 #define IROHA_ABSTRACT_CACHE_HPP 9 #include <boost/optional.hpp> 11 #include <shared_mutex> 25 template <
typename KeyType,
typename ValueType,
typename T>
33 std::shared_lock<std::shared_timed_mutex> lock(access_mutex_);
34 return constUnderlying().getIndexSizeHighImpl();
42 std::shared_lock<std::shared_timed_mutex> lock(access_mutex_);
43 return constUnderlying().getCacheItemCountImpl();
56 void addItem(
const KeyType &key,
const ValueType &value) {
58 std::lock_guard<std::shared_timed_mutex> lock(access_mutex_);
59 underlying().addItemImpl(key, value);
67 boost::optional<ValueType>
findItem(
const KeyType &key)
const {
68 std::shared_lock<std::shared_timed_mutex> lock(access_mutex_);
69 return constUnderlying().findItemImpl(key);
73 const T &constUnderlying()
const {
74 return static_cast<const T &
>(*this);
77 return static_cast<T &
>(*this);
80 mutable std::shared_timed_mutex access_mutex_;
85 #endif // IROHA_ABSTRACT_CACHE_HPP void addItem(const KeyType &key, const ValueType &value)
Definition: abstract_cache.hpp:56
boost::optional< ValueType > findItem(const KeyType &key) const
Definition: abstract_cache.hpp:67
uint32_t getIndexSizeHigh() const
Definition: abstract_cache.hpp:31
Definition: block_query.hpp:15
Definition: abstract_cache.hpp:26
uint32_t getCacheItemCount() const
Definition: abstract_cache.hpp:40