File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package ogdb
2+
3+ // Code using batches should try to add this much data to the batch.
4+ // The value was determined empirically.
5+ const IdealBatchSize = 100 * 1024
6+
7+ // Putter wraps the database write operation supported by both batches and regular databases.
8+ type Putter interface {
9+ Put (key []byte , value []byte ) error
10+ }
11+
12+ // Database wraps all database operations. All methods are safe for concurrent use.
13+ type Database interface {
14+ Putter
15+ Get (key []byte ) ([]byte , error )
16+ Has (key []byte ) (bool , error )
17+ Delete (key []byte ) error
18+ Close ()
19+ NewBatch () Batch
20+ }
21+
22+ // Batch is a write-only database that commits changes to its host database
23+ // when Write is called. Batch cannot be used concurrently.
24+ type Batch interface {
25+ Putter
26+ ValueSize () int // amount of data in the batch
27+ Write () error
28+ // Reset resets the batch for reuse
29+ Reset ()
30+ }
You can’t perform that action at this time.
0 commit comments