Documentation ¶
Index ¶
- Variables
- type Datastore
- func (d *Datastore) Batch(ctx context.Context) (ds.Batch, error)
- func (d *Datastore) Close() error
- func (d *Datastore) CollectGarbage(ctx context.Context) (err 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) GetExpiration(ctx context.Context, key ds.Key) (time.Time, 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) (bool, error)
- func (d *Datastore) NewTransaction(ctx context.Context, readOnly bool) (ds.Txn, error)
- func (d *Datastore) Put(ctx context.Context, key ds.Key, value []byte) error
- func (d *Datastore) PutWithTTL(ctx context.Context, key ds.Key, value []byte, ttl time.Duration) error
- func (d *Datastore) Query(ctx context.Context, q dsq.Query) (dsq.Results, error)
- func (d *Datastore) SetTTL(ctx context.Context, key ds.Key, ttl time.Duration) error
- func (d *Datastore) Sync(ctx context.Context, prefix ds.Key) error
- type Options
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("datastore closed")
Functions ¶
This section is empty.
Types ¶
type Datastore ¶
type Datastore struct { DB *badger.DB // contains filtered or unexported fields }
func NewDatastore ¶
NewDatastore creates a new badger datastore.
DO NOT set the Dir and/or ValuePath fields of opt, they will be set for you.
func (*Datastore) Batch ¶
Batch creates a new Batch object. This provides a way to do many writes, when there may be too many to fit into a single transaction.
func (*Datastore) CollectGarbage ¶
func (*Datastore) DiskUsage ¶
DiskUsage implements the PersistentDatastore interface. It returns the sum of lsm and value log files sizes in bytes.
func (*Datastore) GetExpiration ¶
func (*Datastore) NewTransaction ¶
NewTransaction starts a new transaction. The resulting transaction object can be mutated without incurring changes to the underlying Datastore until the transaction is Committed.
func (*Datastore) PutWithTTL ¶
type Options ¶
type Options struct { // Please refer to the Badger docs to see what this is for GcDiscardRatio float64 // Interval between GC cycles // // If zero, the datastore will perform no automatic garbage collection. GcInterval time.Duration // Sleep time between rounds of a single GC cycle. // // If zero, the datastore will only perform one round of GC per // GcInterval. GcSleep time.Duration // TTL sets the expiration time for all newly added keys. After expiration, // the keys will no longer be retrievable and will be removed by garbage // collection. // // The default value is 0, which means no TTL. TTL time.Duration badger.Options }
Options are the badger datastore options, reexported here for convenience.
var DefaultOptions Options
DefaultOptions are the default options for the badger datastore.
func (Options) WithGcDiscardRatio ¶
WithGcDiscardRatio returns a new Options value with GcDiscardRatio set to the given value.
Please refer to the Badger docs to see what this is for ¶
Default value is 0.2
func (Options) WithGcInterval ¶
WithGcInterval returns a new Options value with GcInterval set to the given value.
GcInterval specifies the interval between garbage collection cycles. If zero, the datastore will perform no automatic garbage collection.
Default value is 15 minutes.
func (Options) WithGcSleep ¶
WithGcSleep returns a new Options value with GcSleep set to the given value.
GcSleep specifies the sleep time between rounds of a single garbage collection cycle. If zero, the datastore will only perform one round of GC per GcInterval.
Default value is 10 seconds.