encapsulate Redis base function

This commit is contained in:
landaiqing
2024-08-06 13:17:03 +08:00
parent d0496b34f0
commit 86b907d4d0
15 changed files with 493 additions and 23 deletions

20
core/redis.go Normal file
View File

@@ -0,0 +1,20 @@
package core
import (
"github.com/redis/go-redis/v9"
"schisandra-cloud-album/global"
)
func InitRedis() {
rdb := redis.NewClient(&redis.Options{
Addr: global.CONFIG.Redis.Addr(),
Password: global.CONFIG.Redis.Password,
DB: global.CONFIG.Redis.Db,
MaxActiveConns: global.CONFIG.Redis.MaxActive,
MaxIdleConns: global.CONFIG.Redis.MaxIdle,
PoolSize: global.CONFIG.Redis.PoolSize,
MinIdleConns: global.CONFIG.Redis.MinIdle,
PoolTimeout: global.CONFIG.Redis.PoolTimeout,
})
global.REDIS = rdb
}