1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00

更新redis

This commit is contained in:
2023-10-13 10:52:36 +08:00
parent e83db7daee
commit d1c269ed90
8 changed files with 48 additions and 42 deletions

View File

@ -7,25 +7,20 @@ import (
"github.com/charlienet/go-mixed/cache/bigcache"
"github.com/charlienet/go-mixed/cache/freecache"
"github.com/charlienet/go-mixed/logx"
"github.com/charlienet/go-mixed/redis"
)
const defaultPrefix = "cache"
type option func(*Cache) error
type options struct {
Prefix string
}
func WithRedis(opts RedisConfig) option {
func WithRedis(rdb redis.Client) option {
return func(c *Cache) error {
if len(opts.Prefix) == 0 {
opts.Prefix = defaultPrefix
}
rds := NewRedis(opts)
rds := NewRedis(rdb)
c.rds = rds
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)