package mount
import "github.com/ipfs/go-datastore/mount"
Package mount provides a Datastore that has other Datastores mounted at various key prefixes and is threadsafe
Index ¶
- Variables
- type Datastore
- func New(mounts []Mount) *Datastore
- func (d *Datastore) Batch(ctx context.Context) (ds.Batch, error)
- func (d *Datastore) Check(ctx context.Context) error
- func (d *Datastore) Close() error
- func (d *Datastore) CollectGarbage(ctx context.Context) error
- func (d *Datastore) Delete(ctx context.Context, key ds.Key) error
- func (d *Datastore) DiskUsage(ctx context.Context) (uint64, error)
- func (d *Datastore) Get(ctx context.Context, key ds.Key) (value []byte, err error)
- func (d *Datastore) GetSize(ctx context.Context, key ds.Key) (size int, err error)
- func (d *Datastore) Has(ctx context.Context, key ds.Key) (exists bool, err error)
- func (d *Datastore) Put(ctx context.Context, key ds.Key, value []byte) error
- func (d *Datastore) Query(ctx context.Context, master query.Query) (query.Results, error)
- func (d *Datastore) Scrub(ctx context.Context) error
- func (d *Datastore) Sync(ctx context.Context, prefix ds.Key) error
- type Mount
Variables ¶
Types ¶
type Datastore ¶
type Datastore struct {
// contains filtered or unexported fields
}
Datastore is a mount datastore. In this datastore, keys live under the most specific mounted sub-datastore. That is, given sub-datastores mounted under:
* / * /foo * /foo/bar
Keys would be written as follows:
* /foo, /foobar, /baz would all live under /. * /foo/baz, /foo/bar, etc. would live under /foo. * /foo/bar/baz would live under /foo/bar.
Additionally, even if the datastore mounted at / contains the key /foo/thing, the datastore mounted at /foo would mask this value in get, deletes, and query results.
Finally, if no root (/) mount is provided, operations on keys living outside all of the provided mounts will behave as follows:
* Get - Returns datastore.ErrNotFound. * Query - Returns no results. * Put - Returns ErrNoMount.
func New ¶
New creates a new mount datstore from the given mounts. See the documentation on Datastore for details.
The order of the mounts does not matter, they will be applied most specific to least specific.
func (*Datastore) Batch ¶
Batch returns a batch that operates over all mounted datastores.
func (*Datastore) Check ¶
func (*Datastore) Close ¶
Close closes all mounted datastores.
func (*Datastore) CollectGarbage ¶
func (*Datastore) Delete ¶
Delete deletes the value associated with the key in the appropriate datastore.
Delete returns no error if there is no value associated with the given key.
func (*Datastore) DiskUsage ¶
DiskUsage returns the sum of DiskUsages for the mounted datastores. Non PersistentDatastores will not be accounted.
func (*Datastore) Get ¶
Get returns the value associated with the key from the appropriate datastore.
func (*Datastore) GetSize ¶
Get returns the size of the value associated with the key in the appropriate datastore.
func (*Datastore) Has ¶
Has returns the true if there exists a value associated with key in the appropriate datastore.
func (*Datastore) Put ¶
Put puts the given value into the datastore at the given key.
Returns ErrNoMount if there no datastores are mounted at the appropriate prefix for the given key.
func (*Datastore) Query ¶
Query queries the appropriate mounted datastores, merging the results according to the given orders.
If a query prefix is specified, Query will avoid querying datastores mounted outside that prefix.
func (*Datastore) Scrub ¶
func (*Datastore) Sync ¶
Sync implements Datastore.Sync
type Mount ¶
Mount defines a datastore mount. It mounts the given datastore at the given prefix.
Source Files ¶
- Version
- v0.8.2 (latest)
- Published
- Mar 4, 2025
- Platform
- linux/amd64
- Imports
- 10 packages
- Last checked
- 1 month ago –
Tools for package owners.