couchdbstore

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CouchDBStore

type CouchDBStore struct {
	// contains filtered or unexported fields
}

CouchDBStore represents a CouchDB-backed database.

func (*CouchDBStore) CreateIndex added in v0.1.3

func (c *CouchDBStore) CreateIndex(createIndexRequest storage.CreateIndexRequest) error

CreateIndex creates an index based on the provided CreateIndexRequest. createIndexRequest.IndexStorageLocation refers to the design doc that the index should get placed in. createIndexRequest.IndexName is the name for the index that will be stored in CouchDB. createIndexRequest.WhatToIndex must be a valid index object as defined here:

http://docs.couchdb.org/en/stable/api/database/find.html#db-index

func (*CouchDBStore) Delete added in v0.1.4

func (c *CouchDBStore) Delete(k string) error

Delete deletes the key-value pair associated with k.

func (*CouchDBStore) Get

func (c *CouchDBStore) Get(k string) ([]byte, error)

Get retrieves the value in the store associated with the given key.

func (*CouchDBStore) GetAll added in v0.1.4

func (c *CouchDBStore) GetAll() (map[string][]byte, error)

GetAll fetches all the key-value pairs within this store. TODO: #61 Add support for pagination.

func (*CouchDBStore) GetBulk added in v0.1.5

func (c *CouchDBStore) GetBulk(keys ...string) ([][]byte, error)

GetBulk fetches the values associated with the given keys. This method works in an all-or-nothing manner. It returns an error if any of the keys don't exist. If even one key is missing, then no values are returned. The end result is equivalent to calling Get(k,v) on each key-value pair individually in a loop, but should be faster since this method minimizes REST calls as long as the values were stored as JSON instead of attachments. If values are stored as attachments, then there are still optimizations that could be done - see TODO #124.

func (*CouchDBStore) Put

func (c *CouchDBStore) Put(k string, v []byte) error

Put stores the given key-value pair in the store. If an existing document is found, it will be overwritten.

func (*CouchDBStore) PutBulk added in v0.1.5

func (c *CouchDBStore) PutBulk(keys []string, values [][]byte) error

PutBulk stores the key-value pairs in the order given in the array. The end result is equivalent to calling Put(k,v) on each key-value pair individually in a loop, but should be faster since this method minimizes REST calls. There is one exception to this equivalency referenced above: in order to minimize REST calls, duplicate keys are removed (along with their associated values), with only the final one remaining. This means that CouchDB will not have any history of those intermediate updates, which it would have had you just used Put(k,v) in a loop. TODO (#120): Add an option to preserve CouchDB history (at the expense of speed).

func (*CouchDBStore) Query added in v0.1.3

func (c *CouchDBStore) Query(findQuery string) (storage.ResultsIterator, error)

Query executes a query using the CouchDB _find endpoint.

type Option added in v0.1.3

type Option func(opts *Provider)

Option configures the couchdb provider.

func WithDBPrefix added in v0.1.3

func WithDBPrefix(dbPrefix string) Option

WithDBPrefix option is for adding prefix to db name.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider represents an CouchDB implementation of the storage.Provider interface.

func NewProvider

func NewProvider(hostURL string, opts ...Option) (*Provider, error)

NewProvider instantiates Provider.

func (*Provider) Close

func (p *Provider) Close() error

Close closes the provider.

func (*Provider) CloseStore

func (p *Provider) CloseStore(name string) error

CloseStore closes a previously opened store.

func (*Provider) CreateStore

func (p *Provider) CreateStore(name string) error

CreateStore creates a new store with the given name.

func (*Provider) OpenStore

func (p *Provider) OpenStore(name string) (storage.Store, error)

OpenStore opens an existing store with the given name and returns it. If the store has been previously opened, it will be returned it from the local cache. Note that if the underlying database was deleted by an external force, (i.e. not by using the CloseStore() method) then this local cache will be invalid. To make it valid again, either a new Provider object needs to be created, or Provider.CreateStore() needs to be called again with the same store name. TODO address this: #51.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL