cache.go 463 B

12345678910111213141516171819202122
  1. package cache
  2. import "github.com/jaryhe/gopkgs/cache/redis"
  3. var redisCache *redis.Redis
  4. // Setup 建立连接
  5. func Setup(addrs []string, passwd string, db int,
  6. poolSize, minIdleConns, maxRetries int, cluster bool) {
  7. // 生成redis连接
  8. redisCache = redis.New(addrs, passwd, db, poolSize, minIdleConns, maxRetries, cluster)
  9. }
  10. // Redis 获取redis句柄
  11. func Redis() *redis.Redis {
  12. return redisCache
  13. }
  14. // Close 关闭
  15. func Close() {
  16. redisCache.Close()
  17. }