From 5e7b7cb449f6b4044bbbae0e9778675fac63633f Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Mon, 27 Jun 2022 16:56:36 +0800 Subject: [PATCH] refactor(sync): add entries cache --- source/libs/sync/src/syncRaftEntry.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c index d221780ae1..225360630c 100644 --- a/source/libs/sync/src/syncRaftEntry.c +++ b/source/libs/sync/src/syncRaftEntry.c @@ -308,6 +308,7 @@ int32_t raftCacheGetEntryP(struct SRaftEntryCache* pCache, SyncIndex index, SSyn int32_t raftCacheDelEntry(struct SRaftEntryCache* pCache, SyncIndex index) { taosThreadMutexLock(&(pCache->mutex)); taosHashRemove(pCache->pEntryHash, &index, sizeof(index)); + --(pCache->currentCount); taosThreadMutexUnlock(&(pCache->mutex)); return 0; } @@ -334,6 +335,8 @@ int32_t raftCacheGetAndDel(struct SRaftEntryCache* pCache, SyncIndex index, SSyn } while (0); taosHashRemove(pCache->pEntryHash, &index, sizeof(index)); + --(pCache->currentCount); + taosThreadMutexUnlock(&(pCache->mutex)); return 0; } @@ -346,6 +349,7 @@ int32_t raftCacheGetAndDel(struct SRaftEntryCache* pCache, SyncIndex index, SSyn int32_t raftCacheClear(struct SRaftEntryCache* pCache) { taosThreadMutexLock(&(pCache->mutex)); taosHashClear(pCache->pEntryHash); + pCache->currentCount = 0; taosThreadMutexUnlock(&(pCache->mutex)); return 0; }