Files
aptly/database/goleveldb/batch.go
Andrey Smirnov 67e38955ae Refactor database code to support standalone batches, transactions.
This is spin-off of changes from #459.

Transactions are not being used yet, but batches are updated to work
with the new API.

`database/` package was refactored to split abstract interfaces and
implementation via goleveldb. This should make it easier to implement
new database types.
2019-08-09 00:46:40 +03:00

35 lines
529 B
Go

package goleveldb
import (
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/opt"
"github.com/aptly-dev/aptly/database"
)
type batch struct {
db *leveldb.DB
b *leveldb.Batch
}
func (b *batch) Put(key, value []byte) error {
b.b.Put(key, value)
return nil
}
func (b *batch) Delete(key []byte) error {
b.b.Delete(key)
return nil
}
func (b *batch) Write() error {
return b.db.Write(b.b, &opt.WriteOptions{})
}
// batch should implement database.Batch
var (
_ database.Batch = &batch{}
)