gosexy / redis

Redis client for Go that maps the full redis command list into equivalent Go functions.
MIT License
167 stars 44 forks source link

Can multiple threads share a *redis.Client object? #13

Closed yesuu closed 11 years ago

yesuu commented 11 years ago

Does each user request is the establishment of a *redis.Client object?

xiam commented 11 years ago

If you use multiple redis.Connect calls you'll be creating new connections to the server but if your goroutines share a common *redis.Client you can expect only one connection stablished.

If you have problems with goroutines that should be filled as a bug, I've made modifications to both gosexy/redis and hiredis.c in order to not have problems with goroutines (hiredis.c was initially refusing to work with concurrent processes).

xiam commented 11 years ago

Just be aware that there are some blocking commands that would indeed block your client connections :), these commands are SUBSCRIBE and PSUBSCRIBE. You should not have problems with any other commands, if you do, please file a bug and attach a code example.