I have previously been using this:
data, err := redis.Bytes(c.Do("GET", key))
to make sure that data returned is a slice of bytes.
However, I now need to add an extra command to the Redis request so I have something like this:
c.Send("MULTI")
c.Send("GET", key)
c.Send("EXPIRE", key)
r, err := c.Do("EXEC")
but now I can't seem to make the GET
command return a slice of bytes. I've tried adding redis.Bytes
like below but no luck.
c.Send("MULTI")
redis.Bytes(c.Send("GET", key))
c.Send("EXPIRE", key)
r, err := c.Do("EXEC")
MULTI
is used to send several commands in an atomic way to Redis, by creating a transaction. This is not a pipeline at all.None of the commands will be actually executed before the
EXEC
call so it is impossible to obtain the value when you callGET
from within a transaction.From the docs:
In redigo pipelining is done in a different way:
http://godoc.org/github.com/garyburd/redigo/redis#hdr-Pipelining
What you want to do is something like this (untested):