Displaying 20 results from an estimated 600 matches similar to: "expiring cache fragments using script/runner"
2006 Apr 08
2
trouble expiring cached pages
I''m having a bear of a time getting my cached pages to expire. Maybe
one of you guys can help me out. I''ll show my sweeper and then my log
to show that it "should" be working.
class PragmaticSweeper < ActionController::Caching::Sweeper
observe Comment
def after_save(comment)
expire_page(comment.post_id)
end
private
def expire_page(post_id)
2008 Apr 01
1
"Undefined method merge" when using sweeper
Hi,
I''m trying to use sweepers for the first time and got a problem - I
get "undefined method `merge'' for "/signature/
f2d7c7c66450b169.html":String". The "/signature/f2d7c7c66450b169.html"
part of the error message is the cached page.
Here''s my sweeper:
class FooSweeper < ActionController::Caching::Sweeper
observe Foo
def
2007 Sep 10
2
expire_page not working
I''ve enabled page caching on a site I''m currently constructing. The
sweeper is called upon any changes made to the model, as expected.
The sweeper code is as follows:
class PersonSweeper < ActionController::Caching::Sweeper
observe Person
def after_update(person)
expire_staff_page
end
def after_destroy(person)
expire_staff_page
end
def
2007 Oct 21
4
Making 'expire_fragment' available to a model?
I noticed a lot of repetition across different Sweeper models in my
app expiring the same fragments and so have been trying to move all
the expire_fragment calls into another model which the sweepers can
then use but it''s not working as I''d hoped..
I''ve created a CacheDestroyer model and want to be able to call
something to the effect of:
2006 Mar 09
0
Caching problem: expire_page not working
Hi all,
I''m new to rails and I''ve run in to a rather insidious bug. In
development (with caching turned on in development.rb), my app
successfully caches action "index" in controller "view":
class ViewController < ApplicationController
caches_page :index
def index
# do the stuff that index does
end
end
I''ve got a sweeper
2007 Feb 14
4
cache sweeper not getting called
Hi,
I''ve started to implement page caches but I''ve hit a brick wall getting
a sweeper to clear the cache when needed. It seems that any models that
I tell it to observe aren''t being observed properly. If I add the
sweeper to a controller the initialize method runs, but no matter what I
do the after_save/after_update callbacks aren''t running. Also if I try
to
2006 Jan 25
1
cache_sweeper causes undefined method error
I created a sweeper ItemSweeper and saved it in
app/models/item_sweeper.rb. Then I put this in my item_controller.rb:
cache_sweeper :item_sweeper, :only => [:create, :destroy, :update]
But now when I call the view action, I get this error:
ActionView::TemplateError (undefined method `title'' for nil:NilClass) on
line #5 of app/views/item/view.rhtml:
5: <H1
2010 Sep 08
0
Re: Call expire_fragment from outside sweepers or controllers
xponrails wrote:
> Hi all.
>
> I need to expire cached fragments from outside sweepers or
> controllers: I have a rake task that calls a method inside a module in
> the /lib directory. This task will be called at a scheduled time by a
> crontab job.
>
> After method execution I would like to expire some cached fragments.
>
> I''ve just tried to import
2008 Sep 28
4
Cannot expire cache from background process?
Hello,
I am trying to expire fragments (or at least trigger their expiration)
from a daemon that''s running in the background.
The daemon is updating all kinds of important lists every few minutes
from the background.
So I have to find some way to DO or TRIGGER the fragment caching from
this daemon.
Unfortunately just using the normal commands like:
expire_fragment :controller =>
2010 Aug 14
0
How do I unit test this?
I''ve got a cache sweeper running observing a model
"after_validation_on_update". Inside that filter method, a call to
"controller.current_user" is made to access that
application_controller method (to get the current user in session).
I get the error "NoMethodError: undefined method `current_user'' for
nil:NilClass" when running my unit test
2009 Dec 16
5
Caching comments: timestamps and subdomains
Hi,
I''m working on a website that has a very slow loading frontpage. I
wanted to start by caching certain elements that have high load. For
example, it loads the last 50 comments, along with the corresponding
usernames, avatars and more. So I cached that fragment and created a
sweeper that observes Comment and expires after every create or
destroy action.
However, I have two problems:
2006 Jan 27
0
Cache Sweepers and runner scripts that act on models?
I created a script that I call by ''./script/runner -e production
UpdateItems.get_new_items()'', which basically calls the model Item:
Item.create(attributes...)
I''ve set up a cache sweeper which removes caches after each
create/destroy/update on Item, and it works fine when accessing
controllers via the web server, but apparently doesn''t work via runner.
2009 Feb 18
4
expire_fragment with memcached
Hello all,
We know that memcached or memcached-client doesn''t support regex... But
It seems it doesn''t support expire_fragment either :/
I''m trying to use expire_fragment with memcached as following :
expire_fragment(:controller => ''home'', :action => :list_posts)
But apparently it''s not supported by memcached :
RuntimeError (Not
2006 Jan 31
2
Fragment caching and pagination
I''m just getting my hands dirty with caching. The pages I want to cache have
some user specific data on them (for example "log out"). That sent me down
the route of fragment caching. One of the things I want to pagination is a
paginated list. My question is how is pagination and query strings handled
with fragment caching? Does each page get its own fragment and query string
2006 Jan 16
0
expire_fragment problem
Hello,
I am trying to invalidate a cached fragment.
My fragment looks like
<% cache (
:controller=>''users'',:action=>''additem_to_cart'',:action_suffix=>@user.id) %>
At this point,rails has created 2 cache files correctly and everything works
fine becuase I dont see rails making calls to the SQL db to get items from
DB.Instead it uses cache.
Now
2006 Jan 21
1
clearing/expiring the ''index'' action.
Hi all,
I''m having problems trying to expire the ''index'' action of a controller.
In short,
expire_action :action => ''index''
doesn''t work, but
expire_fragment (url_for :action =>
''index'').gsub(/\/index/,'''').split("://").last
works fine and deletes the cached page as expected.
I
2006 Jun 14
1
page caching with custom routes
hi ,
I''m having problems with expire_page with custom routes
i''ll show some code
blog_controller
---------------
def clear_cache_rss_artikels
expire_page url_for(:controller => "xml",:action => "rss_artikels")
end
this is called when a new article is posted or edited or destroyed
xml_controller
---------------
class XmlController <
2005 Nov 04
1
expire_fragment outside of a controller
I am trying to figure out a way to call the
expire_fragment outside of a controller. I need to
expire some fragments on a hourly basis. I have a
Thread that every hour that will perform a task. The
expire_fragment is located in the module
ActionController::Caching::Fragments as an instance
method.
Do I need to mixin the model
ActionController::Caching::Fragments into my class?
Or is there
2006 Nov 04
0
#expire_fragment in models...any clean solutions?
I''ve seen a couple of workarounds on the mailing list related to
expiring cached fragments inside of models, but nothing too clean.
Anybody have any suggestions for handling this at the model-level? I
have an application is updated outside of the Rails controllers, so I
can''t use a Sweeper.
The 2 methods I''ve seen:
a. Use a callback to generate an HTTP post on a
2006 Jul 30
0
after_validation_on_update double invokes
Hello to all,
I want to use the after_validation_on_update call back to keep some
redundancy in sync with the model. But now I''ve encountered that the
call-back get called two times. Is this the intended behaviour? What can
I do to prevent Rails from doing so?
best regards
Torsten