Commit f248d49b authored by Raúl Kripalani's avatar Raúl Kripalani

add support for querying entry expiration.

parent bd0caea1
...@@ -138,6 +138,7 @@ type TTLDatastore interface { ...@@ -138,6 +138,7 @@ type TTLDatastore interface {
PutWithTTL(key Key, value []byte, ttl time.Duration) error PutWithTTL(key Key, value []byte, ttl time.Duration) error
SetTTL(key Key, 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 // Txn extends the Datastore type. Txns allow users to batch queries and
......
package query package query
import ( import (
"time"
goprocess "github.com/jbenet/goprocess" goprocess "github.com/jbenet/goprocess"
) )
...@@ -56,18 +58,20 @@ cost of the layer of abstraction. ...@@ -56,18 +58,20 @@ cost of the layer of abstraction.
*/ */
type Query struct { type Query struct {
Prefix string // namespaces the query to results whose keys have Prefix Prefix string // namespaces the query to results whose keys have Prefix
Filters []Filter // filter results. apply sequentially Filters []Filter // filter results. apply sequentially
Orders []Order // order results. apply sequentially Orders []Order // order results. apply sequentially
Limit int // maximum number of results Limit int // maximum number of results
Offset int // skip given number of results Offset int // skip given number of results
KeysOnly bool // return only keys. KeysOnly bool // return only keys.
ReturnExpirations bool // return expirations (see TTLDatastore)
} }
// Entry is a query result entry. // Entry is a query result entry.
type Entry struct { type Entry struct {
Key string // cant be ds.Key because circular imports ...!!! Key string // cant be ds.Key because circular imports ...!!!
Value []byte // Will be nil if KeysOnly has been passed. 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 // Result is a special entry that includes an error, so that the client
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment