Skip to content

Commit

Permalink
Merge pull request #96 from raulk/expiration
Browse files Browse the repository at this point in the history
Add support for querying entry expiration
  • Loading branch information
raulk authored Sep 14, 2018
2 parents bd0caea + 5accf38 commit a350e75
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gx/lastpubver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.0: QmSpg1CvpXQQow5ernt1gNBXaXV6yxyNqi7XoeerWfzB5w
3.2.0: QmUyz7JTJzgegC6tiJrfby3mPhzcdswVtG4x58TQ6pq8jV
1 change: 1 addition & 0 deletions datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ type TTLDatastore interface {

PutWithTTL(key Key, value []byte, ttl time.Duration) error
SetTTL(key Key, ttl time.Duration) error
GetExpiration(key Key) (time.Time, error)
}

// Txn extends the Datastore type. Txns allow users to batch queries and
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
"license": "MIT",
"name": "go-datastore",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "3.1.0"
"version": "3.2.0"
}

20 changes: 12 additions & 8 deletions query/query.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package query

import (
"time"

goprocess "github.com/jbenet/goprocess"
)

Expand Down Expand Up @@ -56,18 +58,20 @@ cost of the layer of abstraction.
*/
type Query struct {
Prefix string // namespaces the query to results whose keys have Prefix
Filters []Filter // filter results. apply sequentially
Orders []Order // order results. apply sequentially
Limit int // maximum number of results
Offset int // skip given number of results
KeysOnly bool // return only keys.
Prefix string // namespaces the query to results whose keys have Prefix
Filters []Filter // filter results. apply sequentially
Orders []Order // order results. apply sequentially
Limit int // maximum number of results
Offset int // skip given number of results
KeysOnly bool // return only keys.
ReturnExpirations bool // return expirations (see TTLDatastore)
}

// Entry is a query result entry.
type Entry struct {
Key string // cant be ds.Key because circular imports ...!!!
Value []byte // Will be nil if KeysOnly has been passed.
Key string // cant be ds.Key because circular imports ...!!!
Value []byte // Will be nil if KeysOnly has been passed.
Expiration time.Time // Entry expiration timestamp if requested and supported (see TTLDatastore).
}

// Result is a special entry that includes an error, so that the client
Expand Down

0 comments on commit a350e75

Please sign in to comment.