Documentation ¶
Index ¶
- type Batch
- type Datastore
- func (d *Datastore) Batch(ctx context.Context) (ds.Batch, error)
- func (d *Datastore) Close() error
- func (d *Datastore) Delete(ctx context.Context, key ds.Key) error
- func (d *Datastore) Get(ctx context.Context, key ds.Key) ([]byte, error)
- func (d *Datastore) GetSize(ctx context.Context, key ds.Key) (int, error)
- func (d *Datastore) Has(ctx context.Context, key ds.Key) (bool, error)
- func (d *Datastore) Put(ctx context.Context, key ds.Key, value []byte) error
- func (d *Datastore) Query(ctx context.Context, q query.Query) (query.Results, error)
- func (d *Datastore) Sync(ctx context.Context, _ ds.Key) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
func (*Batch) Commit ¶
Commit finalizes a transaction, attempting to commit it to the Datastore. May return an error if the transaction has gone stale. The presence of an error is an indication that the data was not committed to the Datastore.
func (*Batch) Delete ¶
Delete removes the value for given `key`. If the key is not in the datastore, this method returns no error.
func (*Batch) Put ¶
Put stores the object `value` named by `key`.
The generalized Datastore interface does not impose a value type, allowing various datastore middleware implementations (which do not handle the values directly) to be composed together.
Ultimately, the lowest-level datastore will need to do some value checking or risk getting incorrect values. It may also be useful to expose a more type-safe interface to your application, and do the checking up-front.
type Datastore ¶
type Datastore struct {
// contains filtered or unexported fields
}
Datastore is a github.com/iotaledger/hive.go/core/kvstore backed github.com/ipfs/go-datastore.
func NewDatastore ¶
NewDatastore creates a kvstore-backed datastore.
func (*Datastore) Delete ¶
Delete removes the value for given `key`. If the key is not in the datastore, this method returns no error.
func (*Datastore) Get ¶
Get retrieves the object `value` named by `key`. Get will return ErrNotFound if the key is not mapped to a value.
func (*Datastore) GetSize ¶
GetSize returns the size of the `value` named by `key`. In some contexts, it may be much cheaper to only get the size of the value rather than retrieving the value itself.
func (*Datastore) Has ¶
Has returns whether the `key` is mapped to a `value`. In some contexts, it may be much cheaper only to check for existence of a value, rather than retrieving the value itself.
func (*Datastore) Put ¶
Put stores the object `value` named by `key`.
The generalized Datastore interface does not impose a value type, allowing various datastore middleware implementations (which do not handle the values directly) to be composed together.
Ultimately, the lowest-level datastore will need to do some value checking or risk getting incorrect values. It may also be useful to expose a more type-safe interface to your application, and do the checking up-front.
func (*Datastore) Query ¶
Query searches the datastore and returns a query result. This function may return before the query actually runs. To wait for the query:
result, _ := ds.Query(q) // use the channel interface; result may come in at different times for entry := range result.Next() { ... } // or wait for the query to be completely done entries, _ := result.Rest() for entry := range entries { ... }
func (*Datastore) Sync ¶
Sync guarantees that any Put or Delete calls under prefix that returned before Sync(prefix) was called will be observed after Sync(prefix) returns, even if the program crashes. If Put/Delete operations already satisfy these requirements then Sync may be a no-op.
If the prefix fails to Sync this method returns an error.