Add RedisFailureState

Taken and slightly modified from:
https://github.com/wsargent/circuit_breaker/pull/8

THe modification was to make the `redis` variable a class variable
rather than an instance variable, so that it can be shared amongst
multiple instances of the circuit breaker.

If this code is used for a purpose other than the search circuit
breaker, this change will require more work.
Changes to support the new RedisFailureState

Allow passing in (and around) the failure state class to use, and the
redis connection.
Update include order

Must include `FailureState` before referencing it.
Refactor passing around of the redis conn

Instead of passing it to the `redis_failure_state` constructor via the
`circuit_state` constructor, set it via a setter on
`redis_failure_state` itself.
Temporary debugging
Fix typo in getter name
Fumbling about with methods
Add SharedState module

SharedState moves the state from an instance variable (different per
request, not useful) to a class variable on the class mixed-in-to.  This
allows the state to be shared by all requests, and thereby be useful.
Modify arguments

An instantiated (and configured) `failure_state` is now passed into this
class.
Add additional states, events, and methods

New state: `closed_initial`
The initial, closed state.  Does not have the `reset_failure_count`
call that the original `closed` state has

New event: `manual_reset`
Resets the state to `half_open` from any other state.  Called in
response to following the `enable` link in the UI.

New method: `trip_immediately`
Trips the circuit breaker and sets `failure_count` and
`last_failure_time` to values that will allow the breaker to remain in
an open state for the configured time.  Called in response to following
the `disable` link in the UI.
Clean up attribute methods and use useful keys

Some identifier for the class CircuitBreaker is mixed in to (`mixee`) is
passed into this class, to be used in the Redis keys.  This allows
storing failure data in Redis on a per-class basis, rather than all
classes using the same two keys.
Changes to support tests

- Treat `:closed_initial` the same as `:closed`
- New event `:reset!` which closes the breaker from *any* state.
Fixes for failing specs

- Reset the breaker between each test method, so state is not shared
  between test runs
- rspec 3.0.1 fix: use `be_truthy` rather than `be_true`.
Redis -> memcached

- Rename RedisFailureState to PersistentFailureState
- Use passed-in `Rails.cache` object, rather than Redis
- Update code to deal with memcached/dalli issue (calling `increment`
  causes subsequent `read` calls to return a bogus value)
Take current circuit state from failure_state

- Pass configured failure threshold value and logger into
  `circuit_state` constructor
- If the current failure count (from the persistent failure state) is
  greater than the failure threshold, log a message and trip the breaker
Merge pull request #1 from envato/persistent-state

Merginating.