Skip to content

Commit

Permalink
去掉无用日志
Browse files Browse the repository at this point in the history
  • Loading branch information
cheerego committed Jun 22, 2022
1 parent 45863fc commit 470c5fc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 0 additions & 4 deletions rlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,10 @@ func (r *RLock) renewExpirationSchedulerGoroutine(cancel context.Context, goid u
}

func (r *RLock) cancelExpirationRenewal(goid uint64) {
fmt.Println("cancel gitid", goid)
entryName := r.g.getEntryName(r.Key)
fmt.Println("cancel entryName", entryName)

entry, ok := r.g.RenewMap.Get(entryName)
if !ok {
fmt.Println("cancel not found", entryName)
return
}
task := entry.(*RenewEntry)
Expand All @@ -179,7 +176,6 @@ func (r *RLock) cancelExpirationRenewal(goid uint64) {
if task.cancelFunc != nil {
task.cancelFunc()
task.cancelFunc = nil
fmt.Println("call cancel function", entryName)
}
r.g.RenewMap.Remove(entryName)
}
Expand Down
18 changes: 18 additions & 0 deletions rlock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,21 @@ func TestPub(t *testing.T) {
rdb.Publish(context.Background(), "123-channel", "123")

}

func TestReLock(t *testing.T) {
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "", // no password set
DB: 0, // use default DB
})

g := NewGodisson(rdb)

lock1 := g.NewRLock("hkn")
t.Log(lock1.TryLock(-1, 30000))
time.Sleep(10 * time.Second)

lock2 := g.NewRLock("hkn")
t.Log(lock2.TryLock(-1, -1))

}

0 comments on commit 470c5fc

Please sign in to comment.