feat: add redis cache

This commit is contained in:
wangfuduo 2025-11-13 18:09:37 +08:00
parent a31c20b173
commit 6bdfa4b438
1 changed files with 23 additions and 0 deletions

23
cache/redis.go vendored Normal file
View File

@ -0,0 +1,23 @@
package cache
import "github.com/go-redis/redis"
var (
redisClient *redis.Client = nil
)
func NewRedis() {
addr := "127.0.0.1:6379"
redis.NewClient(&redis.Options{})
redisClient = redis.NewClient(&redis.Options{
Addr: addr,
})
}
func GetRedis() *redis.Client {
if redisClient == nil {
NewRedis()
}
return redisClient
}