Documentation ¶
Index ¶
- Constants
- Variables
- func PutAll(store KeyValueStore, items ...ListItem) error
- type BlobReader
- type BlobRef
- type BlobWriter
- type Blobs
- type Items
- type IterateOptions
- type Iterator
- type IteratorFunc
- type Key
- type KeyValueStore
- type Keys
- type ListItem
- type ListOptions
- type StaticIterator
- type Value
- type Values
Constants ¶
const Delimiter = '/'
Delimiter separates nested paths in storage
const LookupLimit = 1000
LookupLimit is enforced by storage implementations
Variables ¶
var ErrEmptyKey = errs.Class("empty key")
ErrEmptyKey is returned when an empty key is used in Put
var ErrEmptyQueue = errs.Class("empty queue")
ErrEmptyQueue is returned when attempting to Dequeue from an empty queue
var ErrInvalidBlobRef = errs.Class("invalid blob ref")
ErrInvalidBlobRef is returned when an blob reference is invalid
var ErrKeyNotFound = errs.Class("key not found")
ErrKeyNotFound used When something doesn't exist
var ErrLimitExceeded = errors.New("limit exceeded")
ErrLimitExceeded is returned when request limit is exceeded
Functions ¶
func PutAll ¶
func PutAll(store KeyValueStore, items ...ListItem) error
PutAll adds multiple values to the store
Types ¶
type BlobReader ¶
type BlobReader interface { io.Reader io.ReaderAt io.Seeker io.Closer // Size returns the size of the blob Size() (int64, error) }
BlobReader is an interface that groups Read, ReadAt, Seek and Close.
type BlobWriter ¶
type BlobWriter interface { io.Writer // Cancel discards the blob. Cancel() error // Commit ensures that the blob is readable by others. Commit() error // Size returns the size of the blob Size() (int64, error) }
BlobWriter is an interface that groups Read, ReadAt, Seek and Close.
type Blobs ¶
type Blobs interface { // Create creates a new blob that can be written // optionally takes a size argument for performance improvements, -1 is unknown size Create(ctx context.Context, ref BlobRef, size int64) (BlobWriter, error) // Open opens a reader with the specified namespace and key Open(ctx context.Context, ref BlobRef) (BlobReader, error) // Delete deletes the blob with the namespace and key Delete(ctx context.Context, ref BlobRef) error // FreeSpace return how much free space left for writing FreeSpace() (int64, error) }
Blobs is a blob storage interface
type Items ¶
type Items []ListItem
Items keeps all ListItem
func ListV2 ¶
func ListV2(store KeyValueStore, opts ListOptions) (result Items, more bool, err error)
ListV2 lists all keys corresponding to ListOptions limit is capped to LookupLimit
more indicates if the result was truncated. If false then the result []ListItem includes all requested keys. If true then the caller must call List again to get more results by setting `StartAfter` or `EndBefore` appropriately.
func ReverseItems ¶
ReverseItems reverses items in the list items will be reused and modified TODO: remove this
func SelectPrefixed ¶
SelectPrefixed keeps only items that have prefix items will be reused and modified TODO: remove this
func SortAndCollapse ¶
SortAndCollapse sorts items and combines elements based on Delimiter items will be reused and modified TODO: remove this
type IterateOptions ¶
type IterateOptions struct { // Prefix ensure Prefix Key // First will be the first item iterator returns or the next item (previous when reverse) First Key // Recurse, do not collapse items based on Delimiter Recurse bool // Reverse iterates in reverse order Reverse bool }
IterateOptions contains options for iterator
type Iterator ¶
type Iterator interface { // Next prepares the next list item. // It returns true on success, or false if there is no next result row or an error happened while preparing it. Next(item *ListItem) bool }
Iterator iterates over a sequence of ListItems
type IteratorFunc ¶
IteratorFunc implements basic iterator
func (IteratorFunc) Next ¶
func (next IteratorFunc) Next(item *ListItem) bool
Next returns the next item
type Key ¶
type Key []byte
Key is the type for the keys in a `KeyValueStore`
func (Key) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface for the Key type
type KeyValueStore ¶
type KeyValueStore interface { // Put adds a value to store Put(Key, Value) error // Get gets a value to store Get(Key) (Value, error) // GetAll gets all values from the store GetAll(Keys) (Values, error) // Delete deletes key and the value Delete(Key) error // List lists all keys starting from start and upto limit items List(start Key, limit int) (Keys, error) // Iterate iterates over items based on opts Iterate(opts IterateOptions, fn func(Iterator) error) error // Close closes the store Close() error }
KeyValueStore describes key/value stores like redis and boltdb
type Keys ¶
type Keys []Key
Keys is the type for a slice of keys in a `KeyValueStore`
func ListKeys ¶
func ListKeys(store KeyValueStore, first Key, limit int) (Keys, error)
ListKeys returns keys starting from first and upto limit limit is capped to LookupLimit
func ReverseListKeys ¶
func ReverseListKeys(store KeyValueStore, first Key, limit int) (Keys, error)
ReverseListKeys returns keys starting from first and upto limit in reverse order limit is capped to LookupLimit
func (Keys) ByteSlices ¶
ByteSlices converts a `Keys` struct to a slice of byte-slices (i.e. `[][]byte`)
type ListOptions ¶
type ListOptions struct { Prefix Key StartAfter Key // StartAfter is relative to Prefix EndBefore Key // EndBefore is relative to Prefix Recursive bool IncludeValue bool Limit int }
ListOptions are items that are optional for the LIST method
type StaticIterator ¶
StaticIterator implements an iterator over list of items
func (*StaticIterator) Next ¶
func (it *StaticIterator) Next(item *ListItem) bool
Next returns the next item from the iterator
Directories ¶
Path | Synopsis |
---|---|
schema
Code generated by go-bindata.
|
Code generated by go-bindata. |
redisserver
Package redisserver is package for starting a redis test server
|
Package redisserver is package for starting a redis test server |