mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-18 00:22:41 +08:00
更新redis
This commit is contained in:
11
cache/cache_builder.go
vendored
11
cache/cache_builder.go
vendored
@ -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)
|
||||
|
Reference in New Issue
Block a user