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:
parent
aaea7273c3
commit
352c32ee12
@ -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()
|
||||
}
|
||||
|
@ -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"))
|
||||
})
|
||||
|
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user