增加设置一次性有效租约的方法
This commit is contained in:
@ -159,3 +159,17 @@ func TestWatchKeyOnceForTimeout(t *testing.T) {
|
||||
|
||||
WatchKeyOnce(nil, key, dealFunc, timeout, timeoutFunc)
|
||||
}
|
||||
|
||||
// TestLeaseOnce ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 7:37 下午 2021/11/23
|
||||
func TestLeaseOnce(t *testing.T) {
|
||||
key := "lock"
|
||||
fmt.Println(LeaseOnce(nil, key, "lock", 10))
|
||||
for i := 0; i < 15; i++ {
|
||||
fmt.Println(Get(nil, key, 1))
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user