Store: New Count() function to return count of all records stored.

This commit is contained in:
Kleissner
2021-12-11 13:00:49 +01:00
parent d2bde58d4b
commit 1ece19709e
3 changed files with 15 additions and 0 deletions

View File

@@ -71,3 +71,10 @@ func (ms *MemoryStore) Delete(key []byte) {
delete(ms.data, string(key))
ms.mutex.Unlock()
}
// Count returns the count of records stored.
func (ms *MemoryStore) Count() uint64 {
ms.mutex.Lock()
defer ms.mutex.Unlock()
return uint64(len(ms.data))
}