ledisdb/store/driver/driver.go

78 lines
1.1 KiB
Go
Raw Normal View History

2014-07-25 13:58:00 +04:00
package driver
2014-07-29 13:29:51 +04:00
import (
"errors"
)
var (
ErrTxSupport = errors.New("transaction is not supported")
)
2014-07-25 13:58:00 +04:00
type IDB interface {
Close() error
Get(key []byte) ([]byte, error)
Put(key []byte, value []byte) error
Delete(key []byte) error
2014-10-09 09:05:55 +04:00
SyncPut(key []byte, value []byte) error
SyncDelete(key []byte) error
2014-07-25 13:58:00 +04:00
NewIterator() IIterator
NewWriteBatch() IWriteBatch
2014-07-29 13:29:51 +04:00
2014-08-25 10:18:23 +04:00
NewSnapshot() (ISnapshot, error)
2014-07-29 13:29:51 +04:00
Begin() (Tx, error)
2014-09-12 11:06:36 +04:00
Compact() error
2014-07-25 13:58:00 +04:00
}
2014-08-25 10:18:23 +04:00
type ISnapshot interface {
Get(key []byte) ([]byte, error)
NewIterator() IIterator
Close()
}
2014-07-25 13:58:00 +04:00
type IIterator interface {
Close() error
First()
Last()
Seek(key []byte)
Next()
Prev()
Valid() bool
Key() []byte
Value() []byte
}
type IWriteBatch interface {
Put(key []byte, value []byte)
Delete(key []byte)
Commit() error
2014-10-09 09:05:55 +04:00
SyncCommit() error
2014-07-25 13:58:00 +04:00
Rollback() error
}
2014-07-29 13:29:51 +04:00
type Tx interface {
Get(key []byte) ([]byte, error)
Put(key []byte, value []byte) error
Delete(key []byte) error
NewIterator() IIterator
NewWriteBatch() IWriteBatch
Commit() error
Rollback() error
}
2014-10-29 05:29:35 +03:00
type ISliceGeter interface {
GetSlice(key []byte) (ISlice, error)
}