Versions in this module Expand all Collapse all v1 v1.9.2 Apr 22, 2024 Changes in this version + const DefaultTransactionTimeout + var ErrCommitFailed = DatabaseError(errors.New("unable to commit transaction")) + var ErrKeyNotFound = errors.New("key not found") + var ErrStoreIsClosed = DatabaseError(errors.New("database not open")) + func DatabaseError(err error) error + type AfterCommitOption struct + func (o AfterCommitOption) Invoke(opts []TxOption) + type BytesKey []byte + func (b BytesKey) Bytes() []byte + func (b BytesKey) Equals(other Key) bool + func (b BytesKey) FromBytes(i []byte) (Key, error) + func (b BytesKey) FromString(i string) (Key, error) + func (b BytesKey) Next() Key + func (b BytesKey) String() string + type CallerFn func(key Key, value []byte) error + type Config struct + LockAcquireTimeout time.Duration + Log *logrus.Logger + NoSync bool + func DefaultConfig() Config + type ErrDatabase struct + func (e ErrDatabase) Error() string + func (e ErrDatabase) Is(other error) bool + func (e ErrDatabase) Unwrap() error + type HashKey [32]byte + func (s HashKey) Bytes() []byte + func (s HashKey) Equals(other Key) bool + func (s HashKey) FromBytes(i []byte) (Key, error) + func (s HashKey) FromString(i string) (Key, error) + func (s HashKey) Next() Key + func (s HashKey) String() string + type KVStore interface + Read func(ctx context.Context, fn func(ReadTx) error) error + ReadShelf func(ctx context.Context, shelfName string, fn func(Reader) error) error + Write func(ctx context.Context, fn func(WriteTx) error, opts ...TxOption) error + WriteShelf func(ctx context.Context, shelfName string, fn func(Writer) error) error + type Key interface + Bytes func() []byte + Equals func(other Key) bool + FromBytes func([]byte) (Key, error) + FromString func(string) (Key, error) + Next func() Key + func NewHashKey(bytes [32]byte) Key + type MockKVStore struct + func NewMockKVStore(ctrl *gomock.Controller) *MockKVStore + func (m *MockKVStore) Close(ctx context.Context) error + func (m *MockKVStore) EXPECT() *MockKVStoreMockRecorder + func (m *MockKVStore) Read(ctx context.Context, fn func(ReadTx) error) error + func (m *MockKVStore) ReadShelf(ctx context.Context, shelfName string, fn func(Reader) error) error + func (m *MockKVStore) Write(ctx context.Context, fn func(WriteTx) error, opts ...TxOption) error + func (m *MockKVStore) WriteShelf(ctx context.Context, shelfName string, fn func(Writer) error) error + type MockKVStoreMockRecorder struct + func (mr *MockKVStoreMockRecorder) Close(ctx any) *gomock.Call + func (mr *MockKVStoreMockRecorder) Read(ctx, fn any) *gomock.Call + func (mr *MockKVStoreMockRecorder) ReadShelf(ctx, shelfName, fn any) *gomock.Call + func (mr *MockKVStoreMockRecorder) Write(ctx, fn any, opts ...any) *gomock.Call + func (mr *MockKVStoreMockRecorder) WriteShelf(ctx, shelfName, fn any) *gomock.Call + type MockReadTx struct + func NewMockReadTx(ctrl *gomock.Controller) *MockReadTx + func (m *MockReadTx) EXPECT() *MockReadTxMockRecorder + func (m *MockReadTx) GetShelfReader(shelfName string) Reader + func (m *MockReadTx) Store() KVStore + func (m *MockReadTx) Unwrap() any + type MockReadTxMockRecorder struct + func (mr *MockReadTxMockRecorder) GetShelfReader(shelfName any) *gomock.Call + func (mr *MockReadTxMockRecorder) Store() *gomock.Call + func (mr *MockReadTxMockRecorder) Unwrap() *gomock.Call + type MockReader struct + func NewMockReader(ctrl *gomock.Controller) *MockReader + func (m *MockReader) EXPECT() *MockReaderMockRecorder + func (m *MockReader) Empty() (bool, error) + func (m *MockReader) Get(key Key) ([]byte, error) + func (m *MockReader) Iterate(callback CallerFn, keyType Key) error + func (m *MockReader) Range(from, to Key, callback CallerFn, stopAtNil bool) error + func (m *MockReader) Stats() ShelfStats + type MockReaderMockRecorder struct + func (mr *MockReaderMockRecorder) Empty() *gomock.Call + func (mr *MockReaderMockRecorder) Get(key any) *gomock.Call + func (mr *MockReaderMockRecorder) Iterate(callback, keyType any) *gomock.Call + func (mr *MockReaderMockRecorder) Range(from, to, callback, stopAtNil any) *gomock.Call + func (mr *MockReaderMockRecorder) Stats() *gomock.Call + type MockStore struct + func NewMockStore(ctrl *gomock.Controller) *MockStore + func (m *MockStore) Close(ctx context.Context) error + func (m *MockStore) EXPECT() *MockStoreMockRecorder + type MockStoreMockRecorder struct + func (mr *MockStoreMockRecorder) Close(ctx any) *gomock.Call + type MockTxOption struct + func NewMockTxOption(ctrl *gomock.Controller) *MockTxOption + func (m *MockTxOption) EXPECT() *MockTxOptionMockRecorder + type MockTxOptionMockRecorder struct + type MockWriteTx struct + func NewMockWriteTx(ctrl *gomock.Controller) *MockWriteTx + func (m *MockWriteTx) EXPECT() *MockWriteTxMockRecorder + func (m *MockWriteTx) GetShelfReader(shelfName string) Reader + func (m *MockWriteTx) GetShelfWriter(shelfName string) Writer + func (m *MockWriteTx) Store() KVStore + func (m *MockWriteTx) Unwrap() any + type MockWriteTxMockRecorder struct + func (mr *MockWriteTxMockRecorder) GetShelfReader(shelfName any) *gomock.Call + func (mr *MockWriteTxMockRecorder) GetShelfWriter(shelfName any) *gomock.Call + func (mr *MockWriteTxMockRecorder) Store() *gomock.Call + func (mr *MockWriteTxMockRecorder) Unwrap() *gomock.Call + type MockWriter struct + func NewMockWriter(ctrl *gomock.Controller) *MockWriter + func (m *MockWriter) Delete(key Key) error + func (m *MockWriter) EXPECT() *MockWriterMockRecorder + func (m *MockWriter) Empty() (bool, error) + func (m *MockWriter) Get(key Key) ([]byte, error) + func (m *MockWriter) Iterate(callback CallerFn, keyType Key) error + func (m *MockWriter) Put(key Key, value []byte) error + func (m *MockWriter) Range(from, to Key, callback CallerFn, stopAtNil bool) error + func (m *MockWriter) Stats() ShelfStats + type MockWriterMockRecorder struct + func (mr *MockWriterMockRecorder) Delete(key any) *gomock.Call + func (mr *MockWriterMockRecorder) Empty() *gomock.Call + func (mr *MockWriterMockRecorder) Get(key any) *gomock.Call + func (mr *MockWriterMockRecorder) Iterate(callback, keyType any) *gomock.Call + func (mr *MockWriterMockRecorder) Put(key, value any) *gomock.Call + func (mr *MockWriterMockRecorder) Range(from, to, callback, stopAtNil any) *gomock.Call + func (mr *MockWriterMockRecorder) Stats() *gomock.Call + type MockWriterTTl struct + func NewMockWriterTTl(ctrl *gomock.Controller) *MockWriterTTl + func (m *MockWriterTTl) Delete(key Key) error + func (m *MockWriterTTl) EXPECT() *MockWriterTTlMockRecorder + func (m *MockWriterTTl) Empty() (bool, error) + func (m *MockWriterTTl) Get(key Key) ([]byte, error) + func (m *MockWriterTTl) Iterate(callback CallerFn, keyType Key) error + func (m *MockWriterTTl) Put(key Key, value []byte) error + func (m *MockWriterTTl) PutTTL(key Key, value []byte, duration time.Duration) error + func (m *MockWriterTTl) Range(from, to Key, callback CallerFn, stopAtNil bool) error + func (m *MockWriterTTl) Stats() ShelfStats + type MockWriterTTlMockRecorder struct + func (mr *MockWriterTTlMockRecorder) Delete(key any) *gomock.Call + func (mr *MockWriterTTlMockRecorder) Empty() *gomock.Call + func (mr *MockWriterTTlMockRecorder) Get(key any) *gomock.Call + func (mr *MockWriterTTlMockRecorder) Iterate(callback, keyType any) *gomock.Call + func (mr *MockWriterTTlMockRecorder) Put(key, value any) *gomock.Call + func (mr *MockWriterTTlMockRecorder) PutTTL(key, value, duration any) *gomock.Call + func (mr *MockWriterTTlMockRecorder) Range(from, to, callback, stopAtNil any) *gomock.Call + func (mr *MockWriterTTlMockRecorder) Stats() *gomock.Call + type NilReader struct + func (n NilReader) Empty() (bool, error) + func (n NilReader) Get(_ Key) ([]byte, error) + func (n NilReader) Iterate(_ CallerFn, _ Key) error + func (n NilReader) Range(_ Key, to Key, _ CallerFn, _ bool) error + func (n NilReader) Stats() ShelfStats + type OnRollbackOption struct + func (o OnRollbackOption) Invoke(opts []TxOption) + type Option func(config *Config) + func WithLockAcquireTimeout(value time.Duration) Option + func WithLogger(log *logrus.Logger) Option + func WithNoSync() Option + type ReadTx interface + GetShelfReader func(shelfName string) Reader + Store func() KVStore + Unwrap func() interface{} + type Reader interface + Empty func() (bool, error) + Get func(key Key) ([]byte, error) + Iterate func(callback CallerFn, keyType Key) error + Range func(from Key, to Key, callback CallerFn, stopAtNil bool) error + Stats func() ShelfStats + type ShelfStats struct + NumEntries uint + ShelfSize uint + type Store interface + Close func(ctx context.Context) error + type TxOption interface + func AfterCommit(fn func()) TxOption + func OnRollback(fn func()) TxOption + func WithWriteLock() TxOption + type Uint32Key uint32 + func (u Uint32Key) Bytes() []byte + func (u Uint32Key) Equals(other Key) bool + func (u Uint32Key) FromBytes(i []byte) (Key, error) + func (u Uint32Key) FromString(i string) (Key, error) + func (u Uint32Key) Next() Key + func (u Uint32Key) String() string + type WriteLockOption struct + func (w WriteLockOption) Enabled(opts []TxOption) bool + type WriteTx interface + GetShelfWriter func(shelfName string) Writer + type Writer interface + Delete func(key Key) error + Put func(key Key, value []byte) error + func NewErrorWriter(err error) Writer + type WriterTTl interface + PutTTL func(key Key, value []byte, duration time.Duration) error