abedra/accession — pull request #8 by paraseba (2011-11-29 00:01:57+00:00)
Title: Conn

There was a problem with non ascii strings.
The problem was that all strings sizes were calculated using (count) which is incorrect, because Redis protocol needs number of bytes, not characters.

The first commit adds a failing test for non ascii strings. Next 2 commits fix both writing and reading the Redis protocol.

Possible improvement: right now I'm generating the byte array from the query arguments twice, once when the query is generated (to get the length), and again when the query is sent to Redis. To improve this situation, we could make queries a byte array instead of a string, it should be pretty easy, but, we loose the nice string queries.

Still a problem: we are using (.getBytes "foo") everywhere. This is ugly because depends on the platform encoding to convert from character to byte. A simple improvement would be to force UTF-8 everywhere (super easy). A better approach would be to have :encoding key in the connection map, which would allow the user to change it.

There a couple of duplicated functions in core and request, I only changed those currently being used, I guess the others will be delated.

I think this change is important because it inhibits the use of the library with non-ascii languages. The change should apply cleanly to master too, but let me know if you want a pull request on that branch.

All tests are passing with the patch applied.

Great library by the way! Beautiful how the simplicity of redis and the simplicity of clojure combine.