#20 ✓invalid
Lourens Naude

Versioning model instances

Reported by Lourens Naude | July 25th, 2007 @ 12:14 PM

Chris,

Nice pattern presented here:

http://blog.leetsoft.com/2007/5/...

I think it could be interesting to add a version instance method behaviour much like acts_as_cached :version => X does for migration changes, but wrapped in an after_save callback.

Thoughts?

Comments and changes to this ticket

  • Chris Wanstrath

    Chris Wanstrath July 25th, 2007 @ 12:14 PM

    • State changed from “new” to “open”

    Would the version be an attribute of the model or something? Could you post some pseudo-code, I'm not sure how this would work -- especially if the key depends on a row in the DB.

  • Chris Wanstrath

    Chris Wanstrath July 25th, 2007 @ 12:14 PM

    I should note that this kind of stuff can be done pretty easily by overriding self.cache_key, too. I talk about it a bit in my cache_fu slides -- http://errtheblog.com/post/4872

  • Lourens Naude

    Lourens Naude July 25th, 2007 @ 12:14 PM

    Scrap the above.

    As per Michael Koziarski's suggestion, there might be a sweeter way to do this with Etag headers and the Nginx Memcached module.

    1) Changeset 7580 allows you to specify a custom Etag header - a md5 hashed unique cache key for the request perhaps?

    http://dev.rubyonrails.org/ticke...

    2)The $memcached_key var in Nginx can possibly be assigned the value of the incoming Etag header

    http://wiki.codemongers.com/Ngin...

    3) The biatch is not hitting stale cache keys as Nginx wouldn't bother the backend.

    MemCache#cache_incr can perhaps be used for versioning Etag cache keys in some way or another

    I do realize this is not cache_fu specific so please do ignore if not appropriate / applicable.

  • Chris Wanstrath

    Chris Wanstrath July 25th, 2007 @ 12:14 PM

    • State changed from “open” to “invalid”

    This seems out of the scope of cache_fu, but if you can somehow get some code or a capistrano task out of it, then by all means.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Shared Ticket Bins

Tags

Pages