package utils import ( "eta_gn/eta_task/utils/redis" "time" ) type RedisClient interface { Get(key string) interface{} GetStr(key string) string GetInt64(key string) (int64, error) GetUInt64(key string) (uint64, error) RedisBytes(key string) (data []byte, err error) RedisString(key string) (data string, err error) RedisInt(key string) (data int, err error) Put(key string, val interface{}, timeout time.Duration) error SetNX(key string, val interface{}, timeout time.Duration) bool Delete(key string) error IsExist(key string) bool LPush(key string, val interface{}) error Brpop(key string, callback func([]byte)) GetRedisTTL(key string) time.Duration Incrby(key string, num int) (interface{}, error) Do(commandName string, args ...interface{}) (reply interface{}, err error) } func initRedis(redisType string, conf string) (redisClient RedisClient, err error) { switch redisType { case "cluster": // 集群 redisClient, err = redis.InitClusterRedis(conf) default: // 默认走单机 redisClient, err = redis.InitStandaloneRedis(conf) } return } // RedisNoKeyErr redis没有key的错误 const RedisNoKeyErr = "redis: nil"