Yup, Timothy is correct.

Basically Redis's native datatype is a bytestring: 
http://redis.io/topics/internals-sds.
This is actually more like a JVM ByteArray than String, so libraries
like Jedis (which take Strings), do some coercions for you.

clj-redis uses Jedis underneath, so it expects Strings. But deep-
freeze uses byte[]s, so these coercions are what's causing you
trouble.

You should be able to test this by trying (redis/hmset k k (String.
(deep-freeze/freeze-to-array results)) to freeze and (deep-freeze/thaw-
from-array (.getBytes (redis/hget k k)) to thaw. That should work, but
it's inefficient because you're coercing from byte[]s to String, then
Jedis is coercing from String back to byte[]s.

A better solution would be to communicate with Redis directly with
byte[]s in the first place. This is possible using BinaryJedis, but
there's no support in clj-redis for it yet. I've forked clj-redis and
am slowly doing some experiments here: https://github.com/ptaoussanis/clj-redis
(see binset/binget), but that's FAR from being useable now.


The real problem here is clj-redis not being a good fit for binary
serialization at this point. That will probably improve in time, so if
you'd prefer to stay with clj-redis and you're not in a hurry for
performance I'd probably stick with read/pr-str for now to keeps
things simple.

If you really need the extra performance right now, you'll need to
interface with BinaryJedis directly for values you want to freeze/
thaw.

Hope that helps a bit at least,

--
Peter

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to