Skip to content

Commit

Permalink
Configure Redis for resiliency and reporting
Browse files Browse the repository at this point in the history
By default the RedisCacheStore uses a fault tolerant approach where it
returns nil if it can't access Redis and writes to a logger that we
haven't configured [1].

This isn't an ideal configuration for our use case as it's a critical
problem if the cache isn't available. To try resolve this we've got 3
reconnect attempts available if we don't manage to connect to Redis or
have lost our connection.

In the event that we have an error reading from the cache this will
report the error to sentry, which will hopefully help make problems
easier to diagnose.

[1]: https://github.com/rails/rails/blob/09a2979f75c51afb797dd60261a8930f84144af8/activesupport/lib/active_support/cache/redis_cache_store.rb#L472-L485
  • Loading branch information
kevindew committed Dec 16, 2019
1 parent 566f63a commit 9249b84
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/bulk_data/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def self.clear
def initialize
@cache = ActiveSupport::Cache::RedisCacheStore.new(
namespace: "content-publisher:bulk-data-cache-#{Rails.env}",
error_handler: ->(exception:, **) { GovukError.notify(exception) },
reconnect_attempts: 3,
reconnect_delay: 0.1,
)
end
end
Expand Down

0 comments on commit 9249b84

Please sign in to comment.