1
0
mirror of https://github.com/taigrr/bitcask synced 2025-01-18 04:03:17 -08:00

Add Len() to exported API (extended API)

This commit is contained in:
James Mills 2019-03-21 10:47:50 +10:00
parent aaea7273c3
commit 352c32ee12
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6
3 changed files with 12 additions and 0 deletions

View File

@ -125,6 +125,10 @@ func (b *Bitcask) Scan(prefix string, f func(key string) error) error {
return nil
}
func (b *Bitcask) Len() int {
return b.keydir.Len()
}
func (b *Bitcask) Keys() chan string {
return b.keydir.Keys()
}

View File

@ -40,6 +40,10 @@ func TestAll(t *testing.T) {
assert.Equal([]byte("bar"), val)
})
t.Run("Len", func(t *testing.T) {
assert.Equal(1, db.Len())
})
t.Run("Has", func(t *testing.T) {
assert.True(db.Has("foo"))
})

View File

@ -52,6 +52,10 @@ func (k *Keydir) Delete(key string) {
delete(k.kv, key)
}
func (k *Keydir) Len() int {
return len(k.kv)
}
func (k *Keydir) Keys() chan string {
ch := make(chan string)
go func() {