Some checks failed
Go Tests / Run Tests (1.24.2) (push) Has been cancelled
Adds a complete LSM-based storage engine with these features: - Single-writer based architecture for the storage engine - WAL for durability, and hey it's configurable - MemTable with skip list implementation for fast read/writes - SSTable with block-based structure for on-disk level-based storage - Background compaction with tiered strategy - ACID transactions - Good documentation (I hope)
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package transaction
|
|
|
|
import (
|
|
"github.com/jer/kevo/pkg/common/iterator"
|
|
)
|
|
|
|
// TransactionMode defines the transaction access mode (ReadOnly or ReadWrite)
|
|
type TransactionMode int
|
|
|
|
const (
|
|
// ReadOnly transactions only read from the database
|
|
ReadOnly TransactionMode = iota
|
|
|
|
// ReadWrite transactions can both read and write to the database
|
|
ReadWrite
|
|
)
|
|
|
|
// Transaction represents a database transaction that provides ACID guarantees
|
|
// It follows an concurrency model using reader-writer locks
|
|
type Transaction interface {
|
|
// Get retrieves a value for the given key
|
|
Get(key []byte) ([]byte, error)
|
|
|
|
// Put adds or updates a key-value pair (only for ReadWrite transactions)
|
|
Put(key, value []byte) error
|
|
|
|
// Delete removes a key (only for ReadWrite transactions)
|
|
Delete(key []byte) error
|
|
|
|
// NewIterator returns an iterator for all keys in the transaction
|
|
NewIterator() iterator.Iterator
|
|
|
|
// NewRangeIterator returns an iterator limited to the given key range
|
|
NewRangeIterator(startKey, endKey []byte) iterator.Iterator
|
|
|
|
// Commit makes all changes permanent
|
|
// For ReadOnly transactions, this just releases resources
|
|
Commit() error
|
|
|
|
// Rollback discards all transaction changes
|
|
Rollback() error
|
|
|
|
// IsReadOnly returns true if this is a read-only transaction
|
|
IsReadOnly() bool
|
|
}
|