github.com/koko1123/flow-go-1@v0.29.6/storage/batch.go (about) 1 package storage 2 3 import "github.com/dgraph-io/badger/v3" 4 5 type Transaction interface { 6 Set(key, val []byte) error 7 } 8 9 // BatchStorage serves as an abstraction over batch storage, adding ability to add ability to add extra 10 // callbacks which fire after the batch is successfully flushed. 11 type BatchStorage interface { 12 GetWriter() *badger.WriteBatch 13 14 // OnSucceed adds a callback to execute after the batch has 15 // been successfully flushed. 16 // useful for implementing the cache where we will only cache 17 // after the batch has been successfully flushed 18 OnSucceed(callback func()) 19 20 // Flush will flush the write batch and update the cache. 21 Flush() error 22 }