Karel Minarik
2008-Aug-16 10:26 UTC
expire_fragment_by_glob() for file-based fragment caching patch
Hello all, I have a small patch at http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/832-expire_fragment_by_glob-for-file-based-fragment-caching/ and I''d be interested in your feedback. It is extracted from my current project; motivation was to easily expire file-based fragments for different hostnames where application runs. It adds expire_fragment_by_glob() method to ActionController::Caching::Fragments and takes the "glob" string as argument, same as the Ruby''s `Dir[]` or `Dir#glob`, which I think is great option for matching filesystem paths. I don''t know if file-based fragment cache is getting out of fashion in current development, so would like to know your opinion. Example: expire_fragment_by_glob(''events/{theatre,movie}'') expire_fragment_by_glob(''program/**/*'') I added another method, because there is complex switching logic in expire_fragment (Hash? Regexp?) already. Maybe someone more knowledgeable could refactor it with something like key.is_a?(String) && key.include?(''*'') in the expire_fragment() method... I am quite sure the implementation could be done better :), but I don''t know my way around Rails so well.... Here''s the gist of it: http://gist.github.com/5708 (same as attachment to Lighthouse ticket, but with syntax coloring) Thanks!, Karel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---