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
f248d49b
Commit
f248d49b
authored
Sep 12, 2018
by
Raúl Kripalani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support for querying entry expiration.
parent
bd0caea1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
datastore.go
datastore.go
+1
-0
query/query.go
query/query.go
+12
-8
No files found.
datastore.go
View file @
f248d49b
...
...
@@ -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
...
...
query/query.go
View file @
f248d49b
package
query
import
(
"time"
goprocess
"github.com/jbenet/goprocess"
)
...
...
@@ -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
...
...
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