Documentation ¶
Overview ¶
Package kvdb provides a kvdb interface
Index ¶
- Constants
- Variables
- func RegisterProvider(name string, provider NewFunc)
- type DB
- func (db *DB) Attributes(key string) (types.StringMap, error)
- func (db *DB) Copy(src string, dst string, params ...types.StringMap) error
- func (db *DB) Delete(key string, params ...types.StringMap) error
- func (db *DB) ForEach(prefix string, handler func(key string) error) error
- func (db *DB) Get(key string, params ...types.StringMap) ([]byte, error)
- func (db *DB) Lock(key string, handler func(key string) error, params ...types.StringMap) error
- func (db *DB) OnMiss(handler func(key string, params ...types.StringMap) ([]byte, error), ...)
- func (db *DB) OnUpdate(handler func(key string, val []byte, params ...types.StringMap) error, ...)
- func (db *DB) Put(key string, val []byte, params ...types.StringMap) error
- func (db *DB) Size(key string) (int64, error)
- func (db *DB) URI(key string, params ...types.StringMap) (string, error)
- type NewFunc
- type Provider
Constants ¶
View Source
const ( // OptionExpires is the key kvdb providers should use to set expiration as a time.Duration OptionExpires = "expires" // OptionDB is the database name OptionDB = "db" // OptionPrefix is the prefix the provider should apply to keys OptionPrefix = "prefix" // OptionReadOnly opens the provider in readonly mode OptionReadOnly = "readonly" // OptionMetadata allows adding additional key/value to the object OptionMetadata = "metadata" // OptionKeyTransform provides a func(string)string to transform the key OptionKeyTransform = "key-transform" // OptionValueGetTransform provides a func([]byte])[]byte to transform the value OptionValueGetTransform = "value-transform" // HTTPOptionMethod specifies the method access for the link HTTPOptionMethod = "method" )
Variables ¶
View Source
var ( // ErrObjectStoreNotFound is returned when an object store does not exist ErrObjectStoreNotFound = errors.New("store not found") // ErrObjectNotFound is returned when a object does not exist ErrObjectNotFound = errors.New("object not found") // ErrNotSupported is returned when a provider does not suport the operation ErrNotSupported = errors.New("not supported") // ErrForEachBreak is used to make ForEach stop without an error ErrForEachBreak = errors.New("break from foreach loop") // ErrReadOnly is returned when the provider is readonly ErrReadOnly = errors.New("provider is opened for read-only access") )
Functions ¶
func RegisterProvider ¶
RegisterProvider makes a database provider available by the provided name. If RegisterProvider is called twice with the same name or if provider is nil, it panics.
Types ¶
type DB ¶ added in v2.1.2
type DB struct { Provider // contains filtered or unexported fields }
DB is the kvdb handle
func (*DB) Attributes ¶ added in v2.1.2
Attributes returns provider specific data about the object
func (*DB) OnMiss ¶ added in v2.1.2
func (db *DB) OnMiss(handler func(key string, params ...types.StringMap) ([]byte, error), update bool)
OnMiss allows for handling missing data to be fetched externally and updated
func (*DB) OnUpdate ¶ added in v2.1.2
func (db *DB) OnUpdate(handler func(key string, val []byte, params ...types.StringMap) error, passthru bool)
OnUpdate is called when a value is updated successfully in the store
type Provider ¶
type Provider interface { // Get returns an io.Reader that allows for getting the object data Get(key string, params ...types.StringMap) ([]byte, error) // Put set the value, serializing if necessary Put(key string, val []byte, params ...types.StringMap) error // Delete deletes the key Delete(key string, params ...types.StringMap) error // Copy will copy one key to another Copy(src string, dst string, params ...types.StringMap) error // Lock will lock the key can call the handler and unlock after return Lock(key string, handler func(key string) error, params ...types.StringMap) error // URI returns an accessible URI for the key URI(key string, params ...types.StringMap) (string, error) // Attributes returns provider specific data about the object Attributes(key string) (types.StringMap, error) // Size returns the size of the object Size(key string) (int64, error) // ForEach iterates over the keys in a kvdb ForEach(prefix string, handler func(key string) error) error // PathSeparator is the string used to separate key paths for the provider PathSeparator() string // Name returns the object store name Name() string }
Provider is an interface for kv object stores implemented by providers
Directories ¶
Path | Synopsis |
---|---|
Package providers bootstraps all of the providers
|
Package providers bootstraps all of the providers |
env
Package env provides an os.Environment provider transient kvdb
|
Package env provides an os.Environment provider transient kvdb |
mem
Package mem provides an in-memory transient kvdb
|
Package mem provides an in-memory transient kvdb |
Click to show internal directories.
Click to hide internal directories.