Skip to content

Commit

Permalink
add (*DB[K, V]).Count receiver function
Browse files Browse the repository at this point in the history
  • Loading branch information
knbr13 committed Mar 28, 2024
1 parent 3f2cbcd commit b3ea59e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,10 @@ func (d *DB[K, V]) Close() {
}
d.m = nil
}

// Count returns the number of key-value pairs in the database.
func (d *DB[K, V]) Count() int {
d.mu.RLock()
defer d.mu.RUnlock()
return len(d.m)
}

0 comments on commit b3ea59e

Please sign in to comment.