hi, how can I expire my cached fragments or pages based on time? thanks in advance onur _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 11/19/05, Onur Turgay <onurturgay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi, > > how can I expire my cached fragments or pages based on time? > > thanks in advance > onurUse a cron job. Look at the last modified dates of the files. -- rick http://techno-weenie.net
in php::pear simplecache I could define an expiration date for each cache fiel that I create. So that I didnt violate DRY. If I create cache somewhere but check for it elsewhere I kind of repeat my self. On 11/19/05, Rick Olson <technoweenie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On 11/19/05, Onur Turgay <onurturgay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > hi, > > > > how can I expire my cached fragments or pages based on time? > > > > thanks in advance > > onur > > Use a cron job. Look at the last modified dates of the files. > > -- > rick > http://techno-weenie.net > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 11/19/05, Onur Turgay <onurturgay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> in php::pear simplecache I could define an expiration date for each cache > fiel that I create. So that I didnt violate DRY. If I create cache somewhere > but check for it elsewhere I kind of repeat my self.Isn''t it more dry to use the OS to find and remove old files? At any rate, write a plugin or something to do what you want. I''m guessing no one''s really needed the feature bad enough to implement it. -- rick http://techno-weenie.net
On Nov 19, 2005, at 12:28 PM, Onur Turgay wrote:> hi, > > how can I expire my cached fragments or pages based on time? > > thanks in advance > onurThe easiest way is to use a cron job to either run a script with script/runner that will expire the cached pages. Or you can just have the cron job erase the cached pages in your public directory, HTH- -Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 509-577-7732
For example my latest comments fragment must be expired in 5 minutes. But my tagcloud must be expired in 1 day. If i code this one by one into a cron job, that''ll be unmaintainable. my solution is holding all my caches in database (id, cache_file_name, expire_at) and run a cron job that calls the ubry script that checks this table and expires fragments when necessary. On 11/19/05, Ezra Zygmuntowicz <ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org> wrote:> > > On Nov 19, 2005, at 12:28 PM, Onur Turgay wrote: > > > hi, > > > > how can I expire my cached fragments or pages based on time? > > > > thanks in advance > > onur > > The easiest way is to use a cron job to either run a script with > script/runner that will expire the cached pages. Or you can just have > the cron job erase the cached pages in your public directory, > > HTH- > > -Ezra Zygmuntowicz > WebMaster > Yakima Herald-Republic Newspaper > ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org > 509-577-7732 > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Maybe, this is what you are looking for: http://hybridindie.com/2005/9/19/rubyonrailscaching 2005/11/19, Onur Turgay:> For example my latest comments fragment must be expired in 5 minutes. But my > tagcloud must be expired in 1 day. If i code this one by one into a cron > job, that''ll be unmaintainable. > > my solution is holding all my caches in database (id, cache_file_name, > expire_at) and run a cron job that calls the ubry script that checks this > table and expires fragments when necessary.
On Nov 19, 2005, at 2:39 PM, Onur Turgay wrote:> If i code this one by one into a cron job, that''ll be unmaintainable.Nah.. how is it any less maintainable than doing it any other way??? I say don''t make things complicated. man find look at -[acm]time OR -[acm]min, and -delete oh, and BE CAREFUL (i.e. test with -print before using -delete). --Steve
On 11/19/05, Onur Turgay <onurturgay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> For example my latest comments fragment must be expired in 5 minutes. But my > tagcloud must be expired in 1 day. If i code this one by one into a cron > job, that''ll be unmaintainable. > > my solution is holding all my caches in database (id, cache_file_name, > expire_at) and run a cron job that calls the ubry script that checks this > table and expires fragments when necessary.I just wrote this plugin today for something else, but it may work for you too: http://techno-weenie.net/svn/projects/plugins/referenced_page_caching/ Referenced Page Caching is a small wrapper around Rails'' page caching. It allows you to add references to a current page''s cache file. These references are then used to expire all the pages that are referenced when it is modified or destroyed. -- rick http://techno-weenie.net
whenever I create a new cache type, I will have to go to the cron job and add a sweeping action for it including its expiry time (as every file can have different lifetimes). I think its much more maintainable when you specify the expiry time wherever you define the cache. On 11/20/05, Stephen Waits <steve-g8GSkY9QmIteoWH0uzbU5w@public.gmane.org> wrote:> > > On Nov 19, 2005, at 2:39 PM, Onur Turgay wrote: > > > If i code this one by one into a cron job, that''ll be unmaintainable. > > Nah.. how is it any less maintainable than doing it any other > way??? I say don''t make things complicated. > > man find > > look at -[acm]time OR -[acm]min, and -delete > > oh, and BE CAREFUL (i.e. test with -print before using -delete). > > --Steve > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 11/19/05, Ezra Zygmuntowicz <ezra@yakima-herald.com> wrote:> The easiest way is to use a cron job to either run a script with > script/runner that will expire the cached pages. Or you can just have > the cron job erase the cached pages in your public directory,Hello railers I''m also trying to delete some caching every hour. I''ve set a cron job for executing every hour /home/www/script/runner ''ActionController::Caching::Pages.expire_page( :controller => "home", :action => "index" )'' -e production but it raises an error: /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.1/lib/commands/runner.rb:27: undefined method `expire_page'' for ActionController::Caching::Pages:Module (NoMethodError) Any idea ? Thanks