#15 ✓resolved
Rob Sanheim

update cache_fu to allow action TTL, other stuff

Reported by Rob Sanheim | May 12th, 2007 @ 02:03 PM | in acts_as_cached 2

hi

I've updated cache_fu to allow setting the ttl for action caching on a per action level. This is only enabled when fragment caching is turned on, since once you switch memcache fragments on you have to use memcache for actions also.

The syntax is as follows:

caches_action :index, :page => { :ttl => 5.minutes } # :index uses default ttl, like normal

Or:

caches_action :landing => { :ttl => 20.hours }, :show => { :ttl => 5.minutes }

We don't really need the nested hash, but that keeps it consistent with the rest of the cache_fu API.

This patch also has a couple other assorted things that I fixed as I went:

  • fragment caching will now fallback to the ttl in config first, then it falls back to 25 minutes -- before it would fall back to 25 minutes and ignore the setting in the config.
  • in the test helper, try adding vendor/rails to the load path if possible, so that tests will run against that if you are vendor'ing.
  • use $LOAD_PATH, not $:, more readable
  • rename a fragment cache spec that was a copy and paste error (had a duplicate spec name so probably wasn't running

Comments and changes to this ticket

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

People watching this ticket

Tags

Pages