Skip to content

Commit

Permalink
datastore -> Datastore
Browse files Browse the repository at this point in the history
  • Loading branch information
bigs committed Aug 7, 2018
1 parent c2b3791 commit a05dd3e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ func NewDatastore(path string, options *Options) (*Datastore, error) {
}, nil
}

func (d *datastore) NewTransaction(readOnly bool) ds.Txn {
func (d *Datastore) NewTransaction(readOnly bool) ds.Txn {
return &txn{d.DB.NewTransaction(!readOnly)}
}

func (d *datastore) Put(key ds.Key, value interface{}) error {
func (d *Datastore) Put(key ds.Key, value interface{}) error {
txn := d.NewTransaction(false)
defer txn.Discard()

Expand All @@ -88,7 +88,7 @@ func (d *datastore) Put(key ds.Key, value interface{}) error {
return txn.Commit()
}

func (d *datastore) PutWithTTL(key ds.Key, value interface{}, ttl time.Duration) error {
func (d *Datastore) PutWithTTL(key ds.Key, value interface{}, ttl time.Duration) error {
txn := d.NewTransaction(false).(*txn)
defer txn.Discard()

Expand All @@ -99,7 +99,7 @@ func (d *datastore) PutWithTTL(key ds.Key, value interface{}, ttl time.Duration)
return txn.Commit()
}

func (d *datastore) SetTTL(key ds.Key, ttl time.Duration) error {
func (d *Datastore) SetTTL(key ds.Key, ttl time.Duration) error {
txn := d.NewTransaction(false).(*txn)
defer txn.Discard()

Expand All @@ -110,21 +110,21 @@ func (d *datastore) SetTTL(key ds.Key, ttl time.Duration) error {
return txn.Commit()
}

func (d *datastore) Get(key ds.Key) (value interface{}, err error) {
func (d *Datastore) Get(key ds.Key) (value interface{}, err error) {
txn := d.NewTransaction(true)
defer txn.Discard()

return txn.Get(key)
}

func (d *datastore) Has(key ds.Key) (bool, error) {
func (d *Datastore) Has(key ds.Key) (bool, error) {
txn := d.NewTransaction(true)
defer txn.Discard()

return txn.Has(key)
}

func (d *datastore) Delete(key ds.Key) error {
func (d *Datastore) Delete(key ds.Key) error {
txn := d.NewTransaction(false)
defer txn.Discard()

Expand All @@ -136,7 +136,7 @@ func (d *datastore) Delete(key ds.Key) error {
return txn.Commit()
}

func (d *datastore) Query(q dsq.Query) (dsq.Results, error) {
func (d *Datastore) Query(q dsq.Query) (dsq.Results, error) {
txn := d.NewTransaction(true)
defer txn.Discard()

Expand All @@ -145,22 +145,22 @@ func (d *datastore) Query(q dsq.Query) (dsq.Results, error) {

// DiskUsage implements the PersistentDatastore interface.
// It returns the sum of lsm and value log files sizes in bytes.
func (d *datastore) DiskUsage() (uint64, error) {
func (d *Datastore) DiskUsage() (uint64, error) {
lsm, vlog := d.DB.Size()
return uint64(lsm + vlog), nil
}

func (d *datastore) Close() error {
func (d *Datastore) Close() error {
return d.DB.Close()
}

func (d *datastore) IsThreadSafe() {}
func (d *Datastore) IsThreadSafe() {}

func (d *datastore) Batch() (ds.Batch, error) {
func (d *Datastore) Batch() (ds.Batch, error) {
return d.NewTransaction(false), nil
}

func (d *datastore) CollectGarbage() error {
func (d *Datastore) CollectGarbage() error {
err := d.DB.RunValueLogGC(d.gcDiscardRatio)
if err == badger.ErrNoRewrite {
err = nil
Expand Down

0 comments on commit a05dd3e

Please sign in to comment.