Forum: Ruby on Rails Fragment Cache Wackiness

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ross Karchner (Guest)
on 2006-03-29 06:10
(Received via mailing list)
I can't seem to get the fragment cache to use :file_store. I'd really
appreciate it if someone could point me in the right direction.

Rails 1.1 final, FreeBSD

Observe:

In environment.rb AND production.rb (for good measure, DRY be damned):

ActionController::Base.fragment_cache_store = :file_store,
"/www/apps/localfeeds/directory/tmp/fragmentcache/"


At the console prompt:

Loading production environment.
 >> ActionController::Base.fragment_cache_store
=> #<ActionController::Caching::Fragments::FileStore:0x8f81bac
@cache_path="/www/apps/localfeeds/directory/tmp/fragmentcache/">

In a controller:

class ExportController < ApplicationController
   before_filter :locale_finder
   caches_action :rss, :opml, :top10opml
   ...


Yet tmp/fragmentcache/ remains empty (and removing the directory or
making it unwritable produces no errors in production.log)

I can tell by response times and watching production.log that it IS
caching, so I can only assume it's still using the default in-memory
cache.

A potential wild-card is that I am using this plugin:
http://wiki.rubyonrails.com/rails/pages/Action+Cac...

So I tested without it. Same results.

Any ideas?

-Ross
http://rossnotes.com
Ross Karchner (Guest)
on 2006-03-29 07:44
(Received via mailing list)
Solved!

The rdoc says:
ActionController::Base.fragment_cache_store = :file_store,
"/path/to/cache/directory"

but, Agile...Rails says:

ActionController::Base.fragment_cache_store =
ActionController::Caching::Fragments::FileStore.new(
"#{RAILS_ROOT}/tmp")

I can confirm the Agile syntax works-- is this just a documentation bug?

-Ross
Joe (Guest)
on 2006-03-29 08:14
This is what I have in my environment.rb, within the Initializer.run
block:

config.action_controller.fragment_cache_store = :file_store,
"#{RAILS_ROOT}/cache"

It worked with 1.0. I think it works with 1.1, but haven't confirmed.

Joe
This topic is locked and can not be replied to.