Memcached, marshaling and AR associations

I’m using memcached to cache many AR model objects. I’ve often
wondered if the object’s associations are also stored in the memcached
during marshaling. Does the act of marshaling an object automatically
trigger association loads in the same way that simply referring to an
association triggers a load? That would be bad if your objects had
many large associations that you didn’t want to be stored. Or are only
previously-loaded associations marshaled?

If you are using CachedModel only, then no, it takes care of
associations
not being saved.

But if you are manually marshalling data then yes.

Avoid this by only saving attributes_before_typecast or better yet, only
store an integer reference to your object and fetch it with a db query
(memcached) on page reload.

Vish

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs