CatapultServer  v0.5.0.1 (Elephant)
CacheDatabaseMixin.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "CacheConfiguration.h"
26 
27 namespace catapult { namespace cache {
28 
31  protected:
34  const CacheConfiguration& config,
35  const std::vector<std::string>& columnFamilyNames,
37  : m_pDatabase(config.ShouldUseCacheDatabase
38  ? std::make_unique<CacheDatabase>(CacheDatabaseSettings(
39  config.CacheDatabaseDirectory,
40  GetAdjustedColumnFamilyNames(config, columnFamilyNames),
41  config.MaxCacheDatabaseWriteBatchSize,
42  pruningMode))
43  : std::make_unique<CacheDatabase>())
45  , m_hasPatriciaTreeSupport(config.ShouldStorePatriciaTrees)
46  {}
47 
48  protected:
50  bool hasPatriciaTreeSupport() const {
52  }
53 
56  return *m_pDatabase;
57  }
58 
59  protected:
62  return config.ShouldUseCacheDatabase
65  }
66 
68  void flush() {
70  database().flush();
71  }
72 
73  private:
74  static std::vector<std::string> GetAdjustedColumnFamilyNames(
75  const CacheConfiguration& config,
76  const std::vector<std::string>& columnFamilyNames) {
77  auto adjustedColumnFamilyNames = columnFamilyNames;
78  if (config.ShouldStorePatriciaTrees)
79  adjustedColumnFamilyNames.push_back("patricia_tree");
80 
81  return adjustedColumnFamilyNames;
82  }
83 
84  private:
85  std::unique_ptr<CacheDatabase> m_pDatabase;
88  };
89 }}
ConditionalContainer.h
catapult::cache::CacheDatabaseMixin::GetAdjustedColumnFamilyNames
static std::vector< std::string > GetAdjustedColumnFamilyNames(const CacheConfiguration &config, const std::vector< std::string > &columnFamilyNames)
Definition: CacheDatabaseMixin.h:74
catapult::cache::RocksDatabaseSettings
RocksDb settings.
Definition: RocksDatabase.h:88
catapult::cache::CacheDatabaseMixin::CacheDatabaseMixin
CacheDatabaseMixin(const CacheConfiguration &config, const std::vector< std::string > &columnFamilyNames, FilterPruningMode pruningMode=FilterPruningMode::Disabled)
Creates a mixin around config and columnFamilyNames with optional pruningMode.
Definition: CacheDatabaseMixin.h:33
catapult::cache::CacheDatabaseMixin::hasPatriciaTreeSupport
bool hasPatriciaTreeSupport() const
Returns true if patricia tree support is enabled.
Definition: CacheDatabaseMixin.h:50
UpdateSet.h
catapult::deltaset::ConditionalContainerMode
ConditionalContainerMode
Possible conditional container modes.
Definition: ConditionalContainer.h:43
catapult::cache::CacheConfiguration::ShouldUseCacheDatabase
bool ShouldUseCacheDatabase
true if a cache database should be used, false otherwise.
Definition: CacheConfiguration.h:59
catapult::cache::CacheDatabaseMixin::GetContainerMode
static deltaset::ConditionalContainerMode GetContainerMode(const CacheConfiguration &config)
Gets the container mode specified by config.
Definition: CacheDatabaseMixin.h:61
catapult::cache::FilterPruningMode
FilterPruningMode
Possible modes of rocks pruning filter.
Definition: RocksPruningFilter.h:29
catapult::cache::CacheDatabaseMixin
Mixin that owns a cache database.
Definition: CacheDatabaseMixin.h:30
catapult::deltaset::ConditionalContainerMode::Storage
Delegate to storage.
CacheDatabase.h
catapult::cache::CacheDatabaseMixin::m_hasPatriciaTreeSupport
const bool m_hasPatriciaTreeSupport
Definition: CacheDatabaseMixin.h:87
catapult::cache::CacheDatabaseMixin::m_containerMode
const deltaset::ConditionalContainerMode m_containerMode
Definition: CacheDatabaseMixin.h:86
catapult::cache::CacheDatabaseMixin::m_pDatabase
std::unique_ptr< CacheDatabase > m_pDatabase
Definition: CacheDatabaseMixin.h:85
catapult::cache::FilterPruningMode::Disabled
Disabled, skip allocation of underlying filter implementation.
catapult::cache::RocksDatabase
RocksDb-backed database.
Definition: RocksDatabase.h:116
catapult::cache::CacheDatabaseMixin::database
CacheDatabase & database()
Gets the database.
Definition: CacheDatabaseMixin.h:55
catapult::cache::CacheConfiguration
Cache configuration.
Definition: CacheConfiguration.h:37
catapult::cache::RocksDatabase::flush
void flush()
Finalize batched operations.
Definition: RocksDatabase.cpp:202
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::deltaset::ConditionalContainerMode::Memory
Delegate to memory.
catapult::cache::CacheDatabaseMixin::flush
void flush()
Flushes the database.
Definition: CacheDatabaseMixin.h:68
catapult::cache::CacheConfiguration::ShouldStorePatriciaTrees
bool ShouldStorePatriciaTrees
true if patricia trees should be stored, false otherwise.
Definition: CacheConfiguration.h:68
CacheConfiguration.h