Friday, August 7, 2015

This week in Rails: caching madness, Active Job improvements, and even more performance!

Posted by toddbealmear

What’s up, gang? Todd here with another edition of This Week in Rails. It was a bit of a quiet week in Railsland, but I think we’ve got some quality contributions here. Read on for the deets!

This Week’s Rails Contributors

We had 39 awesome contributors to the Rails codebase this week. Check out the active issues over on GitHub if you’d like to see your name here.

New Stuff

Add #cache_key to ActiveRecord::Relation

This addition bakes a strategy for generating collection cache keys directly into ActiveRecord::Relation. Using #cache_key, it’s now possible to automagically generate a unique key on relations for use with Rails’ fragment cache.

Development Server Caching Toggle

Per a request from DHH, this change adds the ability to enable or disable caching in a development environment. There are two ways to toggle it - on server start with --[no-]dev-caching or with the dev:cache rake task.

Improved

Active Job and Locales

Active Jobs queued with #perform_later previously wouldn’t honor the context’s locale. This patch rectifies that by storing it on the job directly.

Even More Performance Improvements!

By using #start_with? instead of matching on a regex, 765.5 ms have been shaved off of the total aggregate request time per 1000 requests. In conjunction with other performance work recently completed, this knocks a whopping 1.5 seconds off over the course of 1000 requests.

That’s a wrap

That’s all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!

Have you been thinking about writing for us, but you’re scared of putting yourself out there? Don’t worry, you can help our editors improve their writing with thoughtful critique and general grammar policing.

You up for that? Tell Godfrey today.