123456789101112131415161718192021222324252627 |
- package utils
- import (
- "github.com/go-redis/redis"
- "iot_manager_service/config"
- "time"
- )
- var Redis *redis.Client
- func InitRedis() error {
- cfg := config.Instance()
- addr := cfg.Redis.Host
- Redis = redis.NewClient(&redis.Options{
- Addr: addr,
- DialTimeout: 10 * time.Second,
- ReadTimeout: 30 * time.Second,
- WriteTimeout: 30 * time.Second,
- PoolSize: 10,
- PoolTimeout: 30 * time.Second,
- })
- _, err := Redis.Ping().Result()
- if err != nil {
- return err
- }
- return nil
- }
|