refactor(sync): add entries cache
This commit is contained in:
parent
49ff32cda5
commit
5e7b7cb449
|
@ -308,6 +308,7 @@ int32_t raftCacheGetEntryP(struct SRaftEntryCache* pCache, SyncIndex index, SSyn
|
||||||
int32_t raftCacheDelEntry(struct SRaftEntryCache* pCache, SyncIndex index) {
|
int32_t raftCacheDelEntry(struct SRaftEntryCache* pCache, SyncIndex index) {
|
||||||
taosThreadMutexLock(&(pCache->mutex));
|
taosThreadMutexLock(&(pCache->mutex));
|
||||||
taosHashRemove(pCache->pEntryHash, &index, sizeof(index));
|
taosHashRemove(pCache->pEntryHash, &index, sizeof(index));
|
||||||
|
--(pCache->currentCount);
|
||||||
taosThreadMutexUnlock(&(pCache->mutex));
|
taosThreadMutexUnlock(&(pCache->mutex));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -334,6 +335,8 @@ int32_t raftCacheGetAndDel(struct SRaftEntryCache* pCache, SyncIndex index, SSyn
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
taosHashRemove(pCache->pEntryHash, &index, sizeof(index));
|
taosHashRemove(pCache->pEntryHash, &index, sizeof(index));
|
||||||
|
--(pCache->currentCount);
|
||||||
|
|
||||||
taosThreadMutexUnlock(&(pCache->mutex));
|
taosThreadMutexUnlock(&(pCache->mutex));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -346,6 +349,7 @@ int32_t raftCacheGetAndDel(struct SRaftEntryCache* pCache, SyncIndex index, SSyn
|
||||||
int32_t raftCacheClear(struct SRaftEntryCache* pCache) {
|
int32_t raftCacheClear(struct SRaftEntryCache* pCache) {
|
||||||
taosThreadMutexLock(&(pCache->mutex));
|
taosThreadMutexLock(&(pCache->mutex));
|
||||||
taosHashClear(pCache->pEntryHash);
|
taosHashClear(pCache->pEntryHash);
|
||||||
|
pCache->currentCount = 0;
|
||||||
taosThreadMutexUnlock(&(pCache->mutex));
|
taosThreadMutexUnlock(&(pCache->mutex));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue