Documentation ¶
Index ¶
- Variables
- type BadgerStore
- type Binary
- type Bytes
- type Codec
- type GobCodec
- type Iter
- type JSONcodec
- type Option
- type Store
- func NewBadgerKV[K Bytes, V any](dir string, opts ...Option) (Store[K, V], error)
- func NewBadgerKVBytes[K, V Bytes](dir string, opts ...Option) (Store[K, V], error)
- func NewBadgerKVMarhsler[K encoding.BinaryMarshaler, V any, KP binaryPointer[K]](dir string, opts ...Option) (Store[K, V], error)
- func NewMemoryKV[K Bytes, V any]() Store[K, V]
- func PrefixBinary[K encoding.BinaryMarshaler, V any, KP binaryPointer[K]](s Store[K, V], prefix K) (Store[K, V], error)
- func PrefixBytes[K Bytes, V any](s Store[K, V], prefix K) Store[K, V]
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // JSON is a JSONcodec that encodes/decodes Go values to/from JSON. JSON = JSONcodec{} // Gob is a GobCodec that encodes/decodes Go values to/from gob. Gob = GobCodec{} )
Convenience variables
Functions ¶
This section is empty.
Types ¶
type BadgerStore ¶
type BadgerStore interface {
BadgerDB() *badger.DB
}
type Binary ¶
type Binary interface { encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type GobCodec ¶
type GobCodec struct{}
GobCodec encodes/decodes Go values to/from gob. You can use encoding.Gob instead of creating an instance of this struct.
type JSONcodec ¶
type JSONcodec struct{}
JSONcodec encodes/decodes Go values to/from JSON. You can use encoding.JSON instead of creating an instance of this struct.
type Store ¶
type Store[K any, V any] interface { // Set stores the given value for the given key. // The implementation automatically marshalls the value. // The marshalling format depends on the implementation. It can be JSON, gob etc. // The key must not be "" and the value must not be nil. Set(ctx context.Context, k K, v V) error // Get retrieves the value for the given key. // The implementation automatically unmarshalls the value. // The unmarshalling source depends on the implementation. It can be JSON, gob etc. // The automatic unmarshalling requires a pointer to an object of the correct type // being passed as parameter. // In case of a struct the Get method will populate the fields of the object // that the passed pointer points to with the values of the retrieved object's values. // If no value is found it returns (false, nil). // The key must not be "" and the pointer must not be nil. Get(ctx context.Context, k K) (v V, found bool, err error) // Delete deletes the stored value for the given key. // Deleting a non-existing key-value pair does NOT lead to an error. // The key must not be "". Delete(ctx context.Context, k K) error // Close must be called when the work with the key-value store is done. // Most (if not all) implementations are meant to be used long-lived, // so only call Close() at the very end. // Depending on the store implementation it might do one or more of the following: // Make sure all pending updates make their way to disk, // finish open transactions, // close the file handle to an embedded DB, // close the connection to the DB server, // release any open resources, // etc. // Some implementation might not need the store to be closed, // but as long as you work with the kv.Store interface you never know which implementation // is passed to your method, so you should always call it. Close(ctx context.Context) error Range(ctx context.Context, iter Iter[K, V]) error RangeWithPrefix(ctx context.Context, k K, iter Iter[K, V]) error }
func NewBadgerKV ¶
func NewBadgerKVBytes ¶
func NewBadgerKVMarhsler ¶
func NewMemoryKV ¶
func PrefixBinary ¶
Click to show internal directories.
Click to hide internal directories.