Gracefully degrade when cache store goes offline #66

merged 1 commit into from Jun 9, 2012


None yet

4 participants

alau commented May 29, 2012

This fixes issue #42.

When storing a response in MetaStore#store, the cached response body is read
back and subsequently used as response body. If the cache store is offline then
the read-back value may be nil. In that case, the store operation overwrites a
valid response body with nil.

We noticed this problem when we temporarily took down memcached during
maintenance. We expected the site to slow down, but cached pages instead became

The idea of the implementation is to only overwrite the response body if we get
a hit when reading back the body from the cache. The aim is to change as little
code as possible. I do not understand the code base, so there are probably many
assumptions that I am not aware of.

The test creates new stores that implement all(?) abstract methods with
versions that mimic an offline store and then tries to store a value. I'm
unsure whether the preferred style is to define the classes inside or outside
the examples.

Other tests explicitly check that the response body is not the same after
calling #store. I'm assuming that this is because we want to use IO-streams or
something from the backing store, and that it does not apply in this case. I am
unsure though, and would like some feedback on that.

Feedback is more than welcome

@alau alau Gracefully degrade when cache store goes offline
The metastore reads back the cached body after storing it. If the cache
store is offline (e.g. memcached goes down) then the value read back
will be nil. This commit falls back to the original body when that
Mange commented May 29, 2012


rtomayko commented Jun 9, 2012

Looks great. Thanks!

@rtomayko rtomayko merged commit b4f8ce9 into rtomayko:master Jun 9, 2012
grosser commented Oct 2, 2015

@rtomayko can you release that ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment