wuxibin89 / redis-go-cluster

redis cluster client implementation in Go
Apache License 2.0
488 stars 145 forks source link

Add a method that sends a command to each of the cluster nodes #6

Closed flavioaraki closed 8 years ago

flavioaraki commented 8 years ago

As Redis does not allow cross-slot commands, there are situations when it becomes necessary to send a single command to all nodes.

This project already supports cross-slot execution of the command MGET and it would be natural to support other non-cross-slot commands such as SCAN.

The file each_test.go contains an example that sends a SCAN command to all nodes of the cluster. Also note that each_test.go is formatted for godoc, so that it becames an example embedded in the documentation.

Please review and let me know if there are any issues.

Thank you.

wuxibin89 commented 8 years ago

Hi flavioaraki, Thanks for your pull. According to official doc, SCAN is a cursor based command. After every call, server returns a cursor to be used in next call. In cluster situation, each nodes may retun different cursor, which means you can't use a single cursor in next call. You may need redisigning your implementation and more careful tests.

thanks, Joe.

flavioaraki commented 8 years ago

Hi Joe,

Thanks for your feedback.

I'll go back to the drawing board because it is exactly as you pointed out, I would need to return results per node, not combined. 👍

I had only tested with a few keys in each node and the behaviour was good with my proposed implementation, but after testing with many (thousands of) keys, the problems were evident.