Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-datastore
Commits
af96e515
Unverified
Commit
af96e515
authored
Aug 14, 2018
by
bigs
Committed by
GitHub
Aug 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #91 from bigs/feat/superclasses
Add TTL and Transactional interfaces
parents
42d1e120
7db32f20
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
2 deletions
+39
-2
.gx/lastpubver
.gx/lastpubver
+1
-1
datastore.go
datastore.go
+37
-0
package.json
package.json
+1
-1
No files found.
.gx/lastpubver
View file @
af96e515
3.
0
.0: Qm
VG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k
3.
1
.0: Qm
Spg1CvpXQQow5ernt1gNBXaXV6yxyNqi7XoeerWfzB5w
datastore.go
View file @
af96e515
...
@@ -2,6 +2,7 @@ package datastore
...
@@ -2,6 +2,7 @@ package datastore
import
(
import
(
"errors"
"errors"
"time"
query
"github.com/ipfs/go-datastore/query"
query
"github.com/ipfs/go-datastore/query"
)
)
...
@@ -130,6 +131,42 @@ func DiskUsage(d Datastore) (uint64, error) {
...
@@ -130,6 +131,42 @@ func DiskUsage(d Datastore) (uint64, error) {
return
persDs
.
DiskUsage
()
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
// Errors
// ErrNotFound is returned by Get, Has, and Delete when a datastore does not
// ErrNotFound is returned by Get, Has, and Delete when a datastore does not
...
...
package.json
View file @
af96e515
...
@@ -37,6 +37,6 @@
...
@@ -37,6 +37,6 @@
"license"
:
"
MIT
"
,
"license"
:
"
MIT
"
,
"name"
:
"go-datastore"
,
"name"
:
"go-datastore"
,
"releaseCmd"
:
"git commit -a -m
\"
gx publish $VERSION
\"
"
,
"releaseCmd"
:
"git commit -a -m
\"
gx publish $VERSION
\"
"
,
"version"
:
"3.
0
.0"
"version"
:
"3.
1
.0"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment