Avoid taking locks when we don't need to

Former-commit-id: 0d8d3ee9e217cd1f1366a117e6e212f610a028e1
This commit is contained in:
John Sully 2021-06-25 06:11:14 +00:00
parent 165e73353a
commit 0d8da2c350

View File

@ -2726,6 +2726,8 @@ void redisDbPersistentData::ensure(const char *sdsKey, dictEntry **pde)
serverAssert(sdsKey != nullptr);
serverAssert(FImplies(*pde != nullptr, dictGetVal(*pde) != nullptr)); // early versions set a NULL object, this is no longer valid
serverAssert(m_refCount == 0);
if (m_pdbSnapshot == nullptr && g_pserver->m_pstorageFactory == nullptr)
return;
std::unique_lock<fastlock> ul(g_expireLock);
// First see if the key can be obtained from a snapshot