Re: Storing clojure lists and maps in Redis

2012-01-08 Thread Murphy McMahon
It sounds like maybe you've already solved your problem, Shoeb, but just in case: The book _Clojure in Action_ has a section on data mapping and data persistence using Redis. You can download the source code here: http://www.manning.com/rathore/source-code.zip (The relevant files are chapter12_re

Re: Storing clojure lists and maps in Redis

2012-01-06 Thread Alex Miller
BTW, I have not done an actual release of Carbonite to put it out in the repos but I hope to get around to that soon. I have been a bit busy with Clojure/West. :) I plan to set it up in our Revelytix CI server so it can be regularly tested as well. On Jan 6, 12:27 pm, Sam Ritchie wrote: > Pete

Re: Storing clojure lists and maps in Redis

2012-01-06 Thread Sam Ritchie
Peter, Check out Carbonite for a great wrapper library around Kryo. Here are the API tests, with round trip examples: https://github.com/revelytix/carbonite/blob/master/test/carbonite/test_api.clj . Cheers, Sam On Fri, Jan 6, 2012 at 1:30 AM, Peter Taoussanis wrote: > Tim's the one to thank: I

Re: Storing clojure lists and maps in Redis

2012-01-06 Thread Peter Taoussanis
Tim's the one to thank: I didn't do much :) > I did some rudimentary bench marking for large data sets and found > deep-freeze to be 10 times faster on > average compared to JSON serialization. That is really a huge > performance difference. Some final comments if performance really is a major f

Re: Storing clojure lists and maps in Redis

2012-01-06 Thread Shoeb Bhinderwala
Peter/Tim - Also want to commend you on this amazing high performant library (deep- freeze) that you have written. Shoeb On Jan 6, 3:05 am, Shoeb Bhinderwala wrote: > Thanks a lot Peter. Worked great! I did some rudimentary bench marking > for large data sets and found deep-freeze to be 10 time

Re: Storing clojure lists and maps in Redis

2012-01-06 Thread Shoeb Bhinderwala
Thanks a lot Peter. Worked great! I did some rudimentary bench marking for large data sets and found deep-freeze to be 10 times faster on average compared to JSON serialization. That is really a huge performance difference. On Jan 6, 2:19 am, Peter Taoussanis wrote: > Oh wow, sorry- I didn't see

Re: Storing clojure lists and maps in Redis

2012-01-05 Thread Peter Taoussanis
Oh wow, sorry- I didn't see your reply in time and for some reason figured you were using clj-redis. This is actually easier since (if I recall correctly) redis-clojure is able to write byte[]s and has an as-bytes macro for reading. So you'd want something like this (untested): (defn thaw [k]

Re: Storing clojure lists and maps in Redis

2012-01-05 Thread Peter Taoussanis
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 String

Re: Storing clojure lists and maps in Redis

2012-01-05 Thread Shoeb Bhinderwala
Hi Tim I am using redis-clojure client: https://github.com/tavisrudd/redis-clojure Below is the complete code listing. The thaw invocation gives me the error: java.lang.String cannot be cast to [B - (class java.lang.ClassCastException) -- code (ns my-app (:require [redis.c

Re: Storing clojure lists and maps in Redis

2012-01-05 Thread Timothy Baldridge
Can we get a complete code listing? Also what client are you using? It looks as if your redis client is returning a string, and we're expecting a byte array Timothy > I looked at deep-freeze but did not quite understand how to use it. > I used the following to freeze my Clojure complex data struc

Re: Storing clojure lists and maps in Redis

2012-01-05 Thread Shoeb Bhinderwala
Hi Peter - I looked at deep-freeze but did not quite understand how to use it. I used the following to freeze my Clojure complex data structure - results (map of list of maps) and persist to redis:       (redis/hmset k k (deep-freeze/freeze-to-array results)) Then I tried to retrieve and thaw it as

Re: Storing clojure lists and maps in Redis

2012-01-04 Thread Sam Ritchie
Here's an example of a Ring session store that writes clojure maps to and from Redis: https://github.com/wuzhe/clj-redis-session/blob/master/src/clj_redis_session/core.clj In addition to Deep Freeze, you might check out Kryo, accessible via Alex Miller's Carbonite

Re: Storing clojure lists and maps in Redis

2012-01-04 Thread Peter Taoussanis
read/pr-str works well, but it's painfully slow relative to something like Redis. JSON libraries and the like would be faster, but might require more contortions if you're using lots of Clojure data types. My 2c: the best overall compromise atm is the Deep-Freeze serialization library (https://gith

Re: Storing clojure lists and maps in Redis

2012-01-03 Thread Shoeb Bhinderwala
Daniel, Baishampayan - Thanks for the suggestion. I was able to do this extremely easily using the JSON library. I used the json-str and read-json functions. Shoeb On Jan 4, 1:38 am, Baishampayan Ghose wrote: > Shoeb, > > What about storing it as a string? You can either use pr-str or > data.j

Re: Storing clojure lists and maps in Redis

2012-01-03 Thread Softaddicts
We use Clojure's reader representation to serialize data structures as strings here and we still have some Java and JRuby code around. Previously we were using YAML (json was in it's infancy when we opted for YAML). A real pain in the ass... Now we use a couple of protocols callable from every wh

Re: Storing clojure lists and maps in Redis

2012-01-03 Thread Baishampayan Ghose
Shoeb, What about storing it as a string? You can either use pr-str or data.json/generate-string. You can then read it back using read-string or the equivalent json fn. Regards, BG On Wed, Jan 4, 2012 at 12:00 PM, Shoeb Bhinderwala wrote: > I am trying to use Redis as a data structure cache fo

Re: Storing clojure lists and maps in Redis

2012-01-03 Thread Daniel Pittman
On Tue, Jan 3, 2012 at 22:30, Shoeb Bhinderwala wrote: > I am trying to use Redis as a data structure cache for my clojure > application. Does anybody have experience/code/ideas that can write/ > read a clojure complex data structure to the Redis cache. […] > How can I store the above to Redis an

Storing clojure lists and maps in Redis

2012-01-03 Thread Shoeb Bhinderwala
I am trying to use Redis as a data structure cache for my clojure application. Does anybody have experience/code/ideas that can write/ read a clojure complex data structure to the Redis cache. For example I have a list of maps as shown below: (def m1 [{ "total" {:end_mv_base 721470021.02M, :r