rails-assets/rails-assets — pull request #165 by willcosgrove (2014-06-28 06:57:29+00:00)
Title: Added caching for components#index.json

This will speed up the load time of the component list page.

Changes:

* Added [`redis-rails`](https://github.com/redis-store/redis-rails) for caching in Redis
* Moved Component fetching and mapping to json objects into new ComponentHelper
* Added cache fetch for the `ComponentHelper.generate_component_json` in the `component#index.json` action
* Added cache overwriting to the end of the `Reindex` worker

Let me know if you want anything done differently. I moved the Component fetching and json mapping into the `ComponentHelper` because I wanted both the `ComponentController` and the `Reindex` worker to be able to generate the json. This way if something happens with the cache, the ComponentController can, at the worst, revert back to it's previous behavior.

Also, I was sort of taking a guess as to where the best place to do the cache busting/overwriting would be. I picked the `Reindex` worker because it seemed like that's where the database was updated such that it would potentially change the results in the components json info.

I should also mention that I didn't ever run the app and try this, as I'm not quite sure how to test this on my machine. So you might give it a double check before you deploy :)

Thanks!