How to return "[]interface {}" type result
jiashiwen opened this issue · comments
hi,i use redcon build a proxy,an use go-redis to connect server."keys *" command go-redis give me "[]interface {}" type result,and i want to know ,wich conn.WriteXXX method can return this to client,an how todo .
thx
The Redis command KEYS
returns an array of bulk strings.
Using Redcon you can generate an array of bulk strings using the WriteArray()
function, followed by N number of WriteBulkString()
.
So let's say you want to write 5 keys, "key:1", "key:2", "key:3", "key:4", and "key:5".
conn.WriteArray(5)
conn.WriteBulkString("key:1")
conn.WriteBulkString("key:2")
conn.WriteBulkString("key:3")
conn.WriteBulkString("key:4")
conn.WriteBulkString("key:5")
This will be compatible with any Redis client, including go-redis.
I use your method secceed.
Thank you.