Export TTL field (#71)

* add ttl support

Signed-off-by: Connor <zbk602423539@gmail.com>

* fix typo

Signed-off-by: Connor <zbk602423539@gmail.com>

* add get ttl api

Signed-off-by: Connor <zbk602423539@gmail.com>

* export put option field

Signed-off-by: Connor <zbk602423539@gmail.com>

* rename

Signed-off-by: Connor <zbk602423539@gmail.com>
This commit is contained in:
Connor 2021-02-20 15:38:20 +08:00 committed by GitHub
parent c3fd2ee373
commit d52d5aff79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -40,7 +40,7 @@ type ScanOption struct {
// PutOptions is used to provide additional information for put operation.
type PutOption struct {
ttl uint64
TTL uint64
}
func DefaultScanOption() ScanOption {
@ -187,7 +187,7 @@ func (c *Client) Put(ctx context.Context, key, value []byte, options ...PutOptio
var ttl uint64 = 0
if options != nil && len(options) > 0 {
ttl = options[0].ttl
ttl = options[0].TTL
}
req := &rpc.Request{
@ -219,7 +219,7 @@ func (c *Client) BatchPut(ctx context.Context, keys, values [][]byte, options ..
var ttl uint64 = 0
if options != nil && len(options) > 0 {
ttl = options[0].ttl
ttl = options[0].TTL
}
if len(keys) != len(values) {

View File

@ -97,7 +97,7 @@ func (s *testRawKVSuite) mustPut(c *C, key, value []byte) {
}
func (s *testRawKVSuite) mustPutTTL(c *C, key, value []byte, ttl uint64) {
err := s.client.Put(context.TODO(), key, value, PutOption{ ttl: ttl })
err := s.client.Put(context.TODO(), key, value, PutOption{ TTL: ttl })
c.Assert(err, IsNil)
}