
Security News
CISA’s 2025 SBOM Guidance Adds Hashes, Licenses, Tool Metadata, and Context
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
= cache_flow
Drop-dead simple XML fragment caching in Builder templates!
How is it that RESTful web services riding Rails are such a big thing and there doesn't seem to be one definitive, up-to-date reference as to how to cache the XML output? Well cache_flow was built to solve that very problem... and surprisingly easily!
You may be saying to yourself, "Yes, Rails web services are cool, but only if you're using ActiveRecord::Base#to_xml." Agree to disagree. The to_xml approach is just fine, but it seems like scaffolding. I believe there are some serious advantages to building your XML in the view:
== Installation
In environment.rb:
Rails::Initializer.run do |config| config.gem 'cache_flow' end
At your application root, run:
$ sudo rake gems:install
== Example
To cache a chunk of XML, use the one method that cache_flow adds to your Builder instance, aptly named cache!:
xml.users, :type => 'array' do @users.each do |user| xml.cache!(user) do xml.user do xml.first_name user.first_name xml.last_name user.last_name end end end end
It's that easy! The cache! method takes the same arguments as the cache method we all know and love from our ERB views. So in the example above, user.cache_key will be automatically used as the cache key. You get all the same goodies as Rails' built-in fragment caching.
== How It Works
Behind the scenes, cache_flow is using the same mechanism that's used for caching ERB fragments, only using XmlMarkup#target! as its buffer rather than ActionView::Base#output_buffer. I'd like to take more credit, but it really is that simple.
== To-Do
FAQs
Unknown package
We found that cache_flow demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.