cache.go 578 B

12345678910111213141516171819202122232425
  1. // Copyright 2019 getensh.com. All rights reserved.
  2. // Use of this source code is governed by getensh.com.
  3. package cache
  4. import "git.getensh.com/common/gopkgsv2/cache/redis"
  5. var redisCache *redis.Redis
  6. // Setup 建立连接
  7. func Setup(addrs []string, passwd string, db int,
  8. poolSize, minIdleConns, maxRetries int, cluster bool) {
  9. // 生成redis连接
  10. redisCache = redis.New(addrs, passwd, db, poolSize, minIdleConns, maxRetries, cluster)
  11. }
  12. // Redis 获取redis句柄
  13. func Redis() *redis.Redis {
  14. return redisCache
  15. }
  16. // Close 关闭
  17. func Close() {
  18. redisCache.Close()
  19. }