JetThoughts

Redis Store to store session

September 28th 2010

I use Redis to store session and cache. And When I try cache some session values, I get exception “TypeError (can’t dump TCPSocket)”. I have researched this trouble. It was because session.slice(‘keys’) return not simple Hash instance, but SessionHash. So instance method to_hash fix all troubles. Example:

1 Rails.cache.write("key", session.except("flash", :session_id, :_csrf_token))

Solution:

1 Rails.cache.write("key", session.except("flash", :session_id, :_csrf_token).to_hash)
blog comments powered by Disqus

Powered by Rackspace Cloud Computing