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
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
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
Looks great. Thanks!
@rtomayko can you release that ?