tidwall / redcon

Redis compatible server framework for Go
MIT License
2.16k stars 159 forks source link

(empty list or set) problem. #30

Closed hiqsociety closed 4 years ago

hiqsociety commented 4 years ago

I can't seem to generate (empty list or set) with any of the WriteInt WriteString WriteNull or WriteRaw...

how do I return (empty list or set) like normal redis?

127.0.0.1:6380> lrange a 0 1 (empty list or set)

tidwall commented 4 years ago

You'll need to use the WriteArray() function, followed by each item.

For example, let's say you want to print a list of names.

names := []string{"Ichika", "Marie", "Benjamin", "Aya", "Mamadou"}

conn.WriteArray(len(names))
for _, name := range names {
    conn.WriteBulkString(name)
}

The Redcon Write* methods follow the Redis Protocol.

hiqsociety commented 4 years ago

thx! let me repeat again... you are the best!