1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-17 16:12:42 +08:00
Files
go-mixed/locker/redis/redis_store_test.go
2024-05-28 04:23:30 +08:00

32 lines
573 B
Go

package redis
import (
"context"
"testing"
"time"
"github.com/charlienet/go-mixed/redis"
"github.com/charlienet/go-mixed/tests"
)
func TestCreateRedisStore(t *testing.T) {
tests.RunOnDefaultRedis(t, func(rdb redis.Client) {
keyName := "source"
l := NewRedisStore("locker_key", rdb)
ret := l.TryLock(context.Background(), keyName)
if !ret {
t.Log("加锁失败")
}
l.Lock(context.Background(), keyName)
t.Log("锁重入完成")
l.Unlock(context.Background(), keyName)
time.Sleep(time.Second * 15)
// l.Unlock(context.Background())
})
}