tidwall / redcon

Redis compatible server framework for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how does hmget return values? sorry i'm not sure how to use appendbulk etc without examples.

gitmko0 opened this issue · comments

how does hmget return values? sorry i'm not sure how to use appendbulk etc without examples.

According to the Redis website, the hmget command returns an array of bulk strings.

So you would first use AppendArray followed by a number of AppendBulkString (or AppendBulk for byte slices).

Here's an example of how to create a valid Redis response for the HMGET command from an array of Go strings.

strs := []string{ "hello", "world", "planet" }

var resp []byte
resp = redcon.AppendArray(resp, len(strs))
for _, str := range strs {
    resp = redcon.AppendBulkString(resp, str)
}