1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 08:32:40 +08:00
This commit is contained in:
2023-11-03 15:48:14 +08:00
parent 01f426c5b2
commit bdbf18969e
10 changed files with 93 additions and 33 deletions

View File

@ -7,10 +7,17 @@ import (
"sync"
"time"
_ "embed"
"github.com/charlienet/go-mixed/rand"
"github.com/charlienet/go-mixed/redis"
)
//go:embed redis_id_store.lua
var redis_id_function string
var once sync.Once
type redisStore struct {
rdb redis.Client
key string // 缓存键
@ -23,6 +30,8 @@ type redisStore struct {
}
func NewRedisStore(key string, rdb redis.Client) *redisStore {
once.Do(func() { rdb.LoadFunction(redis_id_function) })
return &redisStore{
rdb: rdb,
key: key,