// Copyright (c) 2010 Martin Knafve / hMailServer.com. // http://www.hmailserver.com #pragma once namespace HM { template class CacheReaderWithDbFallback { public: std::shared_ptr GetObject(const SearchType &sName) { auto cache = Cache::Instance(); std::shared_ptr object = cache->GetObject(sName); if (object == nullptr) { // Load the object object = std::shared_ptr(new T); if (!P::ReadObject(object, sName)) { return nullptr; } cache->Add(object); } return object; } }; }