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.

This project is archived and is in readonly mode.

AR::Relation#cache_key

#5731

Provides a unique cache_key for ActiveRecord::Relation. Particularly useful when caching result sets or views:

@results = Person.babies

cache @results.cache_key do
  ...expensive stuff...
end

Reported by joerodriguez (at gmail) · September 29th, 2010 @ 01:28 PM

State: wontfix
Milestone: none
Assigned to: Mikel Lindsaar Mikel Lindsaar
Importance: Low

Activity

  1. Robert Pankowecki
  2. laserlemon
    laserlemon

    It seems like custom cache keys and custom expiration are better suited for these types of situations. A relation's cache key doesn't communicate anything about its expiration. So if another baby were added to the people table, the cache key would remain. I'd just as soon do:

    @results = Person.babies
    
    cache 'people/babies' do
      # Expensive stuff
    end
    

    if I have to expire the cache myself anyway.

    September 29th, 2010 @ 05:16 PM

  3. David Trasbo
    David Trasbo
    • State changed from new to wontfix
    • Importance changed from to Low

    I agree with, erm, laserlemon. Marking this wont fix for now (even though it's not really my decision). Will reopen if this develops further.

    October 9th, 2010 @ 08:17 PM

  4. af001
    af001

    私の中で、総合評価のとっても低いアバアバクロホリスタークロ銀座店。アバクロは大好きなんですけどね。一昨日の東京駅付近での打ち合わせの後、散歩がてら久々に行ってきました。そしたらビックリ!相変わらアバクロず、踊っているだけの店員さんとかもいましたが、

    May 5th, 2011 @ 03:00 AM