CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
28 namespace catapult {
namespace handlers {
31 template<
typename KeyType>
35 template<
typename TCacheDescriptor>
38 using KeyType =
typename TCacheDescriptor::KeyType;
39 using ValueType =
typename TCacheDescriptor::ValueType;
40 using CacheType =
typename TCacheDescriptor::CacheType;
56 using Serializer =
typename TCacheDescriptor::PatriciaTree::Serializer;
58 auto iter = view.find(key);
59 const auto* pEntry = iter.tryGetUnadapted();
60 return pEntry ?
MakeInfo(key, Serializer::SerializeValue(*pEntry)) :
MakeInfo(key);
65 static std::shared_ptr<model::CacheEntryInfo<KeyType>>
MakeInfo(
const KeyType& key) {
66 auto pInfo = std::make_shared<model::CacheEntryInfo<KeyType>>();
73 static std::shared_ptr<model::CacheEntryInfo<KeyType>>
MakeInfo(
const KeyType& key,
const std::string& value) {
75 auto pInfo = utils::MakeSharedWithSize<model::CacheEntryInfo<KeyType>>(
size);
81 : static_cast<uint32_t>(value.size());
83 std::memcpy(pInfo->DataPtr(), value.data(), value.size());
Definition: SynchronizedCache.h:101
supplier< std::shared_ptr< const model::CacheEntryInfo< KeyType > >> CacheEntryInfoProducer
Cache entry info producer.
Definition: CacheEntryInfosProducerFactory.h:32
CacheEntryInfoProducer< KeyType > operator()(const model::EntityRange< KeyType > &ids) const
Creates a cache entry infos producer for a range of keys (ids).
Definition: CacheEntryInfosProducerFactory.h:104
auto operator()()
Definition: CacheEntryInfosProducerFactory.h:54
static std::shared_ptr< model::CacheEntryInfo< KeyType > > MakeInfo(const KeyType &key, const std::string &value)
Definition: CacheEntryInfosProducerFactory.h:73
uint32_t Size
Data size.
Definition: TrailingVariableDataLayout.h:34
CacheEntryInfosProducerFactory(const CacheType &cache)
Definition: CacheEntryInfosProducerFactory.h:92
typename TCacheDescriptor::ValueType ValueType
Definition: CacheEntryInfosProducerFactory.h:39
std::function< T()> supplier
A (stateless) supplier function.
Definition: functions.h:39
typename TCacheDescriptor::KeyType KeyType
Definition: CacheEntryInfosProducerFactory.h:38
Cache entry infos producer factory.
Definition: CacheEntryInfosProducerFactory.h:36
static CacheEntryInfosProducerFactory Create(const CacheType &cache)
Creates a cache entry infos producer factory around cache.
Definition: CacheEntryInfosProducerFactory.h:98
uint64_t size
Definition: MemoryCounters.cpp:65
const CacheType & m_cache
Definition: CacheEntryInfosProducerFactory.h:109
std::shared_ptr< ViewType > m_pView
Definition: CacheEntryInfosProducerFactory.h:88
Definition: CacheEntryInfosProducerFactory.h:42
Definition: AddressExtractionExtension.cpp:28
static std::shared_ptr< model::CacheEntryInfo< KeyType > > MakeInfo(const KeyType &key)
Definition: CacheEntryInfosProducerFactory.h:65
typename TCacheDescriptor::CacheType CacheType
Definition: CacheEntryInfosProducerFactory.h:40
Producer(ViewType &&view, const model::EntityRange< KeyType > &keys)
Definition: CacheEntryInfosProducerFactory.h:48
auto next(TConverter convert)
Produces the next entity and calls convert for any required adaptation.
Definition: BasicProducer.h:38
Cache entry info.
Definition: CacheEntryInfo.h:30
A base class for producers.
Definition: BasicProducer.h:27