For a recent work project at Openbay, we decided to use Resque for our delayed job processing (might move to Sidekiq eventually, but it’s not a priority right now). That meant we had a Redis server already up and running in our environment. When it came time to implement partial caching, we knew that memcache would probably have the best performance, but we already had Redis kicking around anyway, so we figured we’d try using Redis for it instead.
What we forgot to do was to namespace our partial cache. This meant that all of our partials were stored in the same root namespace with everything else, including our delayed jobs.
We eventually noticed that queued jobs were never getting kicked off. While diagnosing the problem, I decided I’d try clearing the cache (for unrelated reasons). Imagine my horror:
1 2 3 4 5 6 7
ZOMG. Rails.cache.clear was wiping out all of our delayed jobs!
The fix was simple enough – namespace your cache entries in your environment.rb file:
Don’t forget to namespace! After that, we were all better:
1 2 3 4 5