update put

This commit is contained in:
白茶清欢 2023-08-15 13:30:56 +08:00
parent aed09507e6
commit 1cff60709c

View File

@ -20,21 +20,22 @@ import (
// Author : go_developer@163.com<白茶清欢> // Author : go_developer@163.com<白茶清欢>
// //
// Date : 12:09 下午 2021/11/23 // Date : 12:09 下午 2021/11/23
func (wc *WrapperClient) Put(ctx context.Context, key string, val string, operateTimeout time.Duration) error { func (wc *WrapperClient) Put(ctx context.Context, key string, val string, operateTimeout time.Duration) (*clientv3.PutResponse, error) {
if operateTimeout <= 0 { if operateTimeout <= 0 {
operateTimeout = DefaultPutTimeout operateTimeout = DefaultPutTimeout
} }
var ( var (
cancel context.CancelFunc cancel context.CancelFunc
err error err error
response *clientv3.PutResponse
) )
if nil == ctx { if nil == ctx {
ctx = context.Background() ctx = context.Background()
} }
ctx, cancel = context.WithTimeout(ctx, operateTimeout) ctx, cancel = context.WithTimeout(ctx, operateTimeout)
_, err = wc.client.Put(ctx, key, val) response, err = wc.client.Put(ctx, key, val)
cancel() cancel()
return err return response, err
} }
// GetWithOption 使用各种option选项读取数据 // GetWithOption 使用各种option选项读取数据