mediocregopher / radix.v2

Redis client for Go
http://godoc.org/github.com/mediocregopher/radix.v2
MIT License
433 stars 92 forks source link

Concurrency safe? #22

Closed awdrius closed 8 years ago

awdrius commented 8 years ago

Hi @mediocregopher, thanks for a nice redis package for go.

A quick question I have is about how well radix.v2 plays with goroutines. Should I do extensive tests and/or add locking around Cmd() calls?

awdrius commented 8 years ago

Sorry, was looking for a label to apply.

mediocregopher commented 8 years ago

Hi awdrius! The main redis package is not threadsafe, a single *redis.Client is simply a wrapper around a net.Conn with no additional locking. If you wish to share connections amongst multiple go-routines I recommend looking at radix's pool package. If your use-case is super simple, like a one-off script, a sync.Mutex around a single *redis.Client may also suffice.

Hopefully this answers your question :)

awdrius commented 8 years ago

Yeap, it's what I was wondering about. I'm using cluster connection so I think I'm just going to deal with it myself. Thanks @mediocregopher