diff --git a/.gx/lastpubver b/.gx/lastpubver index 60e073b..83ff6be 100644 --- a/.gx/lastpubver +++ b/.gx/lastpubver @@ -1 +1 @@ -3.0.0: QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k +3.1.0: QmSpg1CvpXQQow5ernt1gNBXaXV6yxyNqi7XoeerWfzB5w diff --git a/datastore.go b/datastore.go index 091e157..884bf12 100644 --- a/datastore.go +++ b/datastore.go @@ -2,6 +2,7 @@ package datastore import ( "errors" + "time" query "github.com/ipfs/go-datastore/query" ) @@ -130,6 +131,42 @@ func DiskUsage(d Datastore) (uint64, error) { return persDs.DiskUsage() } +// TTLDatastore is an interface that should be implemented by datastores that +// support expiring entries. +type TTLDatastore interface { + Datastore + + PutWithTTL(key Key, value []byte, ttl time.Duration) error + SetTTL(key Key, ttl time.Duration) error +} + +// Txn extends the Datastore type. Txns allow users to batch queries and +// mutations to the Datastore into atomic groups, or transactions. Actions +// performed on a transaction will not take hold until a successful call to +// Commit has been made. Likewise, transactions can be aborted by calling +// Discard before a successful Commit has been made. +type Txn interface { + Datastore + + // 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. + Commit() error + // Discard throws away changes recorded in a transaction without committing + // them to the underlying Datastore. Any calls made to Discard after Commit + // has been successfully called will have no effect on the transaction and + // state of the Datastore, making it safe to defer. + Discard() +} + +// TxnDatastore is an interface that should be implemented by datastores that +// support transactions. +type TxnDatastore interface { + Datastore + + NewTransaction(readOnly bool) Txn +} + // Errors // ErrNotFound is returned by Get, Has, and Delete when a datastore does not diff --git a/package.json b/package.json index e84cc32..a0c8c7b 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,6 @@ "license": "MIT", "name": "go-datastore", "releaseCmd": "git commit -a -m \"gx publish $VERSION\"", - "version": "3.0.0" + "version": "3.1.0" }