我正在尝试从我的 Go Consumer 将数据推送到 redis 队列中。
我使用的包是“github.com/kavu/go-resque”
我使用的redis驱动程序是“github.com/kavu/go-resque/go-redis”和“github.com/go-redis/redis”
我的代码如下所示:
"github.com/kavu/go-resque"
_"github.com/kavu/go-resque/go-redis"
"github.com/go-redis/redis"
"time"
"strings"
redisClient := redis.NewClient(&redis.Options{
Addr: myRedisIp,
Password: "", // no password set
DB: 0, // use default DB
DialTimeout: 10 * time.Second,
})
enqueuer := resque.NewRedisEnqueuer("go-redis", redisClient,"test-redis")
_, err := enqueuer.Enqueue("resque:queue:myQueueName", "Demo::Job", 1, 2, "test")
if err != nil {
fmt.Println("putting into queue failed error="+err.Error())
}else{
fmt.Println("putting into queue success")
}
守着一只汪
相关分类