togglz/togglz — pull request #90 by fchaillou (2014-05-23 20:54:44+00:00)
Title: Cache Repository: Don't reset the featureState if the delegate return null and we have an expired state

Hello,

In our environment we are using a CachingStateRepository on top of a JDBCStateRepository.
We have some issues with our database connections and it brought up that if the JDBC repository fails then the Caching repository will remove the previous value from its cache and replace it with null.

So if the feature was enabled then when the JDBCStateRepository fails we will returns as if the feature was disabled.

What i propose instead is that we reuse the cached state even if it is expired. The next time the cache repository will be hit, we will requiry the delegate because the entry is still expired. (I don't see a way where the delegate state would change without being know by the CachingStateRepository)