mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
feat kvpair include ttl
This commit is contained in:
parent
63456b5c4b
commit
7b60f8bdc3
@ -1,11 +1,17 @@
|
|||||||
package store
|
package store
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
// When user list a directory, we add all the node into key-value pair slice
|
// When user list a directory, we add all the node into key-value pair slice
|
||||||
type KeyValuePair struct {
|
type KeyValuePair struct {
|
||||||
Key string `json:"key, omitempty"`
|
Key string `json:"key, omitempty"`
|
||||||
Value string `json:"value,omitempty"`
|
Value string `json:"value,omitempty"`
|
||||||
Dir bool `json:"dir,omitempty"`
|
Dir bool `json:"dir,omitempty"`
|
||||||
KVPairs kvPairs `json:"kvs,omitempty"`
|
Expiration *time.Time `json:"expiration,omitempty"`
|
||||||
|
TTL int64 `json:"ttl,omitempty"` // Time to live in second
|
||||||
|
KVPairs kvPairs `json:"kvs,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type kvPairs []KeyValuePair
|
type kvPairs []KeyValuePair
|
||||||
|
@ -322,6 +322,7 @@ func (n *Node) Pair(recurisive, sorted bool) KeyValuePair {
|
|||||||
Key: n.Path,
|
Key: n.Path,
|
||||||
Dir: true,
|
Dir: true,
|
||||||
}
|
}
|
||||||
|
pair.Expiration, pair.TTL = n.ExpirationAndTTL()
|
||||||
|
|
||||||
if !recurisive {
|
if !recurisive {
|
||||||
return pair
|
return pair
|
||||||
@ -354,10 +355,12 @@ func (n *Node) Pair(recurisive, sorted bool) KeyValuePair {
|
|||||||
return pair
|
return pair
|
||||||
}
|
}
|
||||||
|
|
||||||
return KeyValuePair{
|
pair := KeyValuePair{
|
||||||
Key: n.Path,
|
Key: n.Path,
|
||||||
Value: n.Value,
|
Value: n.Value,
|
||||||
}
|
}
|
||||||
|
pair.Expiration, pair.TTL = n.ExpirationAndTTL()
|
||||||
|
return pair
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) UpdateTTL(expireTime time.Time) {
|
func (n *Node) UpdateTTL(expireTime time.Time) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user