mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-17 02:47:51 +01:00
Store: New Count() function to return count of all records stored.
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
@@ -69,3 +69,8 @@ func (store *PogrebStore) Get(key []byte) (data []byte, found bool) {
|
||||
func (store *PogrebStore) Delete(key []byte) {
|
||||
store.db.Delete(key)
|
||||
}
|
||||
|
||||
// Count returns the count of records stored.
|
||||
func (store *PogrebStore) Count() uint64 {
|
||||
return uint64(store.db.Count())
|
||||
}
|
||||
|
||||
@@ -29,4 +29,7 @@ type Store interface {
|
||||
|
||||
// ExpireKeys is called to delete all keys that are marked for expiration.
|
||||
ExpireKeys()
|
||||
|
||||
// Count returns the total number of records stored.
|
||||
Count() uint64
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user