86 _container.template
get<Hash>().reserve(maxElements);
87#ifdef LSST_CACHE_DEBUG
88 _debuggingEnabled =
false;
91 _requests.reserve(maxElements);
102#ifdef LSST_CACHE_DEBUG
130 template <
typename Generator>
154 void add(Key
const&
key, Value
const& value);
188 std::optional<Value>
get(Key
const&
key) {
189 auto result = _lookup(
key);
191 return std::optional<Value>(result.first->second);
193 return std::optional<Value>();
217#ifdef LSST_CACHE_DEBUG
218 void enableDebugging() { _debuggingEnabled =
true; }
232 typedef std::pair<Key, Value> Element;
239 typedef boost::multi_index_container<
241 boost::multi_index::indexed_by<
242 boost::multi_index::sequenced<boost::multi_index::tag<Sequence>>,
243 boost::multi_index::hashed_unique<
244 boost::multi_index::tag<Hash>,
245 boost::multi_index::member<Element, Key, &Element::first>,
246 KeyHash>>> Container;
253 std::pair<typename Container::template index<Hash>::type::iterator,
bool> _lookup(Key
const& key) {
254 auto const& hashContainer = _container.template
get<Hash>();
255 auto it = hashContainer.find(key);
256 bool found = (it != hashContainer.end());
258 _container.relocate(_container.template
get<Sequence>().begin(),
259 _container.template project<Sequence>(it));
261#ifdef LSST_CACHE_DEBUG
262 if (_debuggingEnabled) {
263 _requests.push_back(key);
272 void _addNew(Key
const& key, Value
const& value) {
273 _container.template
get<Sequence>().emplace_front(key, value);
277 std::size_t _maxElements;
278 Container _container;
279#ifdef LSST_CACHE_DEBUG
280 bool _debuggingEnabled;
281 mutable std::size_t _hits, _total;
282 mutable std::vector<Key> _requests;
283 static std::size_t getId() {
284 static std::size_t _id = 0;