Blog

Caching Asynchronous Queries in Backbone.js

I was working on a Backbone project with fellow Quick Left-er Bob Bonifield recently, when we came across a problem. We were building an administration panel to be used internally by a client, and there were a couple of views that needed to display the same information about users in a slightly different way. To prevent unnecessary AJAX calls, we decided to cache the result of Backbone.Model#fetch at two levels of our application. The result: less network time and a snappier user experience. Here's how we did it.

Read More

Faking Regex-Based Cache Keys in Rails

There are many ways to cache data in a Rails application. (The official Rails Guide explains the different approaches well.) Heroku allows you to easily take advantage of Rails caching by connecting your application to Memcached servers through the Dalli client gem.

This drop in solution is simple, but there's one glaring problem. Memcache does not support expiring cache keys with regex. This means if you need to delete keys beginning with "user-1" but not keys beginning with "user-2", you're out of luck. Or so it seems...

Read More

Handling the Headaches of Big Data with Rails

We recently worked on a mapping application that lets users monitor their driving habits using real time data from their cars. The data came in the form of latitude/longitude points, from which we would build a trip and calculate statistics for that trip (speeding, distance, etc).

Because the car sends lat/long data every second, a Trip object can contain thousands of points. Each of these points in turn stores the standard rails timestamps, the latitude and longitude themselves, and some relational keys.

Read More