mirror of
https://github.com/taigrr/bitcask
synced 2025-01-18 04:03:17 -08:00
Add Has() to exported API (extended API)
This commit is contained in:
parent
7a427a237a
commit
962e53af17
@ -79,6 +79,11 @@ func (b *Bitcask) Get(key string) ([]byte, error) {
|
|||||||
return e.Value, nil
|
return e.Value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Bitcask) Has(key string) bool {
|
||||||
|
_, ok := b.keydir.Get(key)
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
func (b *Bitcask) Put(key string, value []byte) error {
|
func (b *Bitcask) Put(key string, value []byte) error {
|
||||||
if len(key) > b.config.MaxKeySize {
|
if len(key) > b.config.MaxKeySize {
|
||||||
return ErrKeyTooLarge
|
return ErrKeyTooLarge
|
||||||
|
@ -40,6 +40,10 @@ func TestAll(t *testing.T) {
|
|||||||
assert.Equal([]byte("bar"), val)
|
assert.Equal([]byte("bar"), val)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("Has", func(t *testing.T) {
|
||||||
|
assert.True(db.Has("foo"))
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("Fold", func(t *testing.T) {
|
t.Run("Fold", func(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
keys []string
|
keys []string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user