mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
31 lines
837 B
Go
31 lines
837 B
Go
|
|
package shyftdb
|
|
|
|
// Code using batches should try to add this much data to the batch.
|
|
// The value was determined empirically.
|
|
const IdealBatchSize = 100 * 1024
|
|
|
|
// Putter wraps the database write operation supported by both batches and regular databases.
|
|
type Putter interface {
|
|
Put(key []byte, value []byte) error
|
|
}
|
|
|
|
// Database wraps all database operations. All methods are safe for concurrent use.
|
|
type Database interface {
|
|
Putter
|
|
Get(key []byte) ([]byte, error)
|
|
Has(key []byte) (bool, error)
|
|
Delete(key []byte) error
|
|
Close()
|
|
NewBatch() Batch
|
|
}
|
|
|
|
// Batch is a write-only database that commits changes to its host database
|
|
// when Write is called. Batch cannot be used concurrently.
|
|
type Batch interface {
|
|
Putter
|
|
ValueSize() int // amount of data in the batch
|
|
Write() error
|
|
// Reset resets the batch for reuse
|
|
Reset()
|
|
}
|