You are viewing a read-only archive of the Blogs.Harvard network. Learn more.

Sessions are not caches

August 9th, 2010

Is it just a coincidence that Episode 13 is fraught with danger?

In Dangers of Model in Session, Ryan devotes a whole episode to remind us not to store complex objects in our session.

Objects that are okay to store are very simple objects such as arrays, and strings, and ids, and hashes, and integers. But complex objects like models should be kept inside the database where the results are fetched every time.

There were a couple of comments on this post where folks noted performance problems as a reason to persist an object, but Ryan answers:

If you need a performance boost, look into a memcache solution.

But Ryan, I have to wait till episode #115!

Entry Filed under: Professional,Railscasts Project,Ruby on Rails

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>