2022-01-09 05:59:30 +00:00
|
|
|
# bitcask
|
|
|
|
|
2022-02-23 15:53:55 +00:00
|
|
|
`import "git.tcp.direct/tcp.direct/database/bitcask"`
|
2022-02-12 08:11:09 +00:00
|
|
|
|
|
|
|
## Documentation
|
|
|
|
|
2022-07-26 04:57:01 +00:00
|
|
|
#### func SetDefaultBitcaskOptions
|
|
|
|
|
|
|
|
```go
|
|
|
|
func SetDefaultBitcaskOptions(bitcaskopts ...bitcask.Option)
|
|
|
|
```
|
|
|
|
SetDefaultBitcaskOptions options will set the options used for all subsequent
|
|
|
|
bitcask stores that are initialized.
|
|
|
|
|
|
|
|
#### func WithMaxDatafileSize
|
|
|
|
|
|
|
|
```go
|
|
|
|
func WithMaxDatafileSize(size int) bitcask.Option
|
|
|
|
```
|
|
|
|
WithMaxDatafileSize is a shim for bitcask's WithMaxDataFileSize function.
|
|
|
|
|
|
|
|
#### func WithMaxKeySize
|
|
|
|
|
|
|
|
```go
|
|
|
|
func WithMaxKeySize(size uint32) bitcask.Option
|
|
|
|
```
|
|
|
|
WithMaxKeySize is a shim for bitcask's WithMaxKeySize function.
|
|
|
|
|
|
|
|
#### func WithMaxValueSize
|
|
|
|
|
|
|
|
```go
|
|
|
|
func WithMaxValueSize(size uint64) bitcask.Option
|
|
|
|
```
|
|
|
|
WithMaxValueSize is a shim for bitcask's WithMaxValueSize function.
|
|
|
|
|
2022-01-09 05:59:30 +00:00
|
|
|
#### type DB
|
|
|
|
|
|
|
|
```go
|
2022-07-26 04:57:01 +00:00
|
|
|
type DB struct {
|
|
|
|
}
|
2022-01-09 05:59:30 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
DB is a mapper of a Filer and Searcher implementation using Bitcask.
|
|
|
|
|
|
|
|
#### func OpenDB
|
|
|
|
|
|
|
|
```go
|
|
|
|
func OpenDB(path string) *DB
|
|
|
|
```
|
|
|
|
OpenDB will either open an existing set of bitcask datastores at the given
|
|
|
|
directory, or it will create a new one.
|
|
|
|
|
2022-07-26 04:57:01 +00:00
|
|
|
#### func (*DB) AllStores
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (db *DB) AllStores() []database.Filer
|
|
|
|
```
|
|
|
|
AllStores returns a list of all bitcask datastores.
|
|
|
|
|
2022-01-09 05:59:30 +00:00
|
|
|
#### func (*DB) Close
|
|
|
|
|
|
|
|
```go
|
2022-01-19 09:46:51 +00:00
|
|
|
func (db *DB) Close(storeName string) error
|
2022-01-09 05:59:30 +00:00
|
|
|
```
|
|
|
|
Close is a simple shim for bitcask's Close function.
|
|
|
|
|
|
|
|
#### func (*DB) CloseAll
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (db *DB) CloseAll() error
|
|
|
|
```
|
|
|
|
CloseAll closes all bitcask datastores.
|
|
|
|
|
|
|
|
#### func (*DB) Init
|
|
|
|
|
|
|
|
```go
|
2022-07-26 04:57:01 +00:00
|
|
|
func (db *DB) Init(storeName string, opts ...any) error
|
2022-01-09 05:59:30 +00:00
|
|
|
```
|
2022-01-19 09:46:51 +00:00
|
|
|
Init opens a bitcask store at the given path to be referenced by storeName.
|
2022-01-09 05:59:30 +00:00
|
|
|
|
|
|
|
#### func (*DB) Path
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (db *DB) Path() string
|
|
|
|
```
|
2022-01-19 09:46:51 +00:00
|
|
|
Path returns the base path where we store our bitcask "stores".
|
2022-01-09 05:59:30 +00:00
|
|
|
|
|
|
|
#### func (*DB) Sync
|
|
|
|
|
|
|
|
```go
|
2022-01-19 09:46:51 +00:00
|
|
|
func (db *DB) Sync(storeName string) error
|
2022-01-09 05:59:30 +00:00
|
|
|
```
|
|
|
|
Sync is a simple shim for bitcask's Sync function.
|
|
|
|
|
|
|
|
#### func (*DB) SyncAll
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (db *DB) SyncAll() error
|
|
|
|
```
|
|
|
|
SyncAll syncs all bitcask datastores.
|
|
|
|
|
|
|
|
#### func (*DB) SyncAndCloseAll
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (db *DB) SyncAndCloseAll() error
|
|
|
|
```
|
2022-07-26 04:57:01 +00:00
|
|
|
SyncAndCloseAll implements the method from Keeper to sync and close all bitcask
|
|
|
|
stores.
|
2022-01-09 05:59:30 +00:00
|
|
|
|
|
|
|
#### func (*DB) With
|
|
|
|
|
|
|
|
```go
|
2022-07-26 04:57:01 +00:00
|
|
|
func (db *DB) With(storeName string) database.Store
|
2022-01-09 05:59:30 +00:00
|
|
|
```
|
|
|
|
With calls the given underlying bitcask instance.
|
|
|
|
|
2022-07-26 04:57:01 +00:00
|
|
|
#### func (*DB) WithNew
|
2022-01-09 05:59:30 +00:00
|
|
|
|
|
|
|
```go
|
2022-07-26 04:57:01 +00:00
|
|
|
func (db *DB) WithNew(storeName string) database.Filer
|
2022-01-09 05:59:30 +00:00
|
|
|
```
|
2022-07-26 04:57:01 +00:00
|
|
|
WithNew calls the given underlying bitcask instance, if it doesn't exist, it
|
|
|
|
creates it.
|
2022-01-09 05:59:30 +00:00
|
|
|
|
|
|
|
#### type Store
|
|
|
|
|
|
|
|
```go
|
|
|
|
type Store struct {
|
|
|
|
*bitcask.Bitcask
|
|
|
|
database.Searcher
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Store is an implmentation of a Filer and a Searcher using Bitcask.
|
|
|
|
|
2022-08-29 06:44:32 +00:00
|
|
|
#### func (Store) Backend
|
2022-01-09 05:59:30 +00:00
|
|
|
|
|
|
|
```go
|
2022-08-29 06:44:32 +00:00
|
|
|
func (s Store) Backend() any
|
2022-01-09 05:59:30 +00:00
|
|
|
```
|
2022-08-29 06:44:32 +00:00
|
|
|
Backend returns the underlying bitcask instance.
|
2022-01-09 05:59:30 +00:00
|
|
|
|
2022-08-29 06:44:32 +00:00
|
|
|
#### func (Store) Keys
|
2022-07-26 04:57:01 +00:00
|
|
|
|
|
|
|
```go
|
2022-08-29 06:44:32 +00:00
|
|
|
func (s Store) Keys() (keys [][]byte)
|
2022-07-26 04:57:01 +00:00
|
|
|
```
|
2022-08-29 06:44:32 +00:00
|
|
|
Keys will return all keys in the database as a slice of byte slices.
|
2022-07-26 04:57:01 +00:00
|
|
|
|
2022-01-09 05:59:30 +00:00
|
|
|
#### func (Store) PrefixScan
|
|
|
|
|
|
|
|
```go
|
2022-07-26 04:57:01 +00:00
|
|
|
func (s Store) PrefixScan(prefix string) (<-chan *kv.KeyValue, chan error)
|
2022-01-09 05:59:30 +00:00
|
|
|
```
|
|
|
|
PrefixScan will scan a Store for all keys that have a matching prefix of the
|
|
|
|
given string and return a map of keys and values. (map[Key]Value)
|
|
|
|
|
|
|
|
#### func (Store) Search
|
|
|
|
|
|
|
|
```go
|
2022-07-26 04:57:01 +00:00
|
|
|
func (s Store) Search(query string) (<-chan *kv.KeyValue, chan error)
|
2022-01-09 05:59:30 +00:00
|
|
|
```
|
|
|
|
Search will search for a given string within all values inside of a Store. Note,
|
|
|
|
type casting will be necessary. (e.g: []byte or string)
|
|
|
|
|
|
|
|
#### func (Store) ValueExists
|
|
|
|
|
|
|
|
```go
|
2022-07-26 04:36:46 +00:00
|
|
|
func (s Store) ValueExists(value []byte) (key []byte, ok bool)
|
2022-01-09 05:59:30 +00:00
|
|
|
```
|
|
|
|
ValueExists will check for the existence of a Value anywhere within the
|
2022-08-29 06:44:32 +00:00
|
|
|
keyspace; returning the first Key found, true if found || nil and false if not
|
|
|
|
found.
|