mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
refs #684, #766, #776 Support %OwnerName% in cache keys by allowing CCached::m_element to be a dummy
and by using a trick with explicit destructor call and placement new to reconstruct CCached when owner's name changes.
This commit is contained in:
@@ -309,6 +309,11 @@ namespace BlackMisc
|
||||
CData(T *owner) :
|
||||
CData::CCached(CDataCache::instance(), Trait::key(), Trait::humanReadable(), Trait::isValid, Trait::defaultValue(), owner)
|
||||
{
|
||||
if (! this->isInitialized())
|
||||
{
|
||||
this->onOwnerNameChanged([this, owner] { Private::reconstruct(this, owner); });
|
||||
return;
|
||||
}
|
||||
if (Trait::timeToLive() >= 0) { CDataCache::instance()->setTimeToLive(this->getKey(), Trait::timeToLive()); }
|
||||
if (Trait::isPinned()) { CDataCache::instance()->pinValue(this->getKey()); }
|
||||
if (Trait::isDeferred()) { CDataCache::instance()->deferValue(this->getKey()); }
|
||||
|
||||
Reference in New Issue
Block a user