Skip to content

Commit

Permalink
Improve the distributed lock module
Browse files Browse the repository at this point in the history
  • Loading branch information
dobyte committed Feb 18, 2025
1 parent 58acf7d commit d91e2e0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 29 deletions.
4 changes: 0 additions & 4 deletions lock/memcache/maker.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,3 @@ func (m *Maker) swap(ctx context.Context, key, version string, expiration int32)

return nil
}

func (m *Maker) Get(key string) (*memcache.Item, error) {
return m.opts.client.Get(key)
}
26 changes: 1 addition & 25 deletions lock/memcache/maker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package memcache_test
import (
"context"
"github.com/dobyte/due/lock/memcache/v2"
"github.com/dobyte/due/v2/utils/xconv"
"sync"
"testing"
"time"
Expand All @@ -18,30 +17,7 @@ func TestMaker_Make(t *testing.T) {
t.Fatal(err)
}

go func() {
timer := time.NewTicker(500 * time.Millisecond)
defer timer.Stop()

for {
<-timer.C

item, err := maker.Get("lock:lockName")
if err != nil {
t.Log(err)
continue
}

t.Log(time.Now(), xconv.String(item.Value))
}
}()

go func() {
time.AfterFunc(3*time.Second, func() {
locker.Release(context.Background())
})
}()

//defer locker.Release(context.Background())
defer locker.Release(context.Background())

time.Sleep(20 * time.Second)
}
Expand Down

0 comments on commit d91e2e0

Please sign in to comment.