Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Versioning model instances

#20

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?

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

State: invalid
Milestone: none
Assigned to: Chris Wanstrath Chris Wanstrath

Activity

  1. Chris Wanstrath
    Chris Wanstrath
    • 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.

    July 25th, 2007 @ 12:14 PM

  2. Chris Wanstrath
    Chris Wanstrath

    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

    July 25th, 2007 @ 12:14 PM

  3. Lourens Naude
    Lourens Naude

    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.

    July 25th, 2007 @ 12:14 PM

  4. Chris Wanstrath
    Chris Wanstrath
    • 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.

    July 25th, 2007 @ 12:14 PM

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.