增加设置一次性有效租约的方法

This commit is contained in:
2021-11-23 19:39:52 +08:00
parent 0b5e55cefd
commit 29cb4a4fba
2 changed files with 57 additions and 0 deletions

View File

@ -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)
}
}