github.com/cr-mao/goredislock package
package main
import (
"context"
"github.com/cr-mao/goredislock"
"github.com/go-redis/redis/v8"
"time"
)
//func GetMD5Hash(text string) string {
// hash := md5.Sum([]byte(text))
// return hex.EncodeToString(hash[:])
//}
//
//func GetSHA256(password string) string {
// hash := sha256.New()
// hash.Write([]byte(password))
// res := hex.EncodeToString(hash.Sum(nil))
// return res
//}
func main() {
RedisClient := redis.NewClient(&redis.Options{
Addr: "",
Username: "",
Password: "",
PoolSize: 10, // 连接池大小
})
locker, _ := goredislock.NewLocker("GetSeasonBusinessID",
goredislock.WithContext(context.Background()),
goredislock.WithExpire(time.Second*3), goredislock.WithRedisClient(RedisClient),
).Lock()
defer locker.Unlock()
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。