diff --git a/neat_cache/CHANGELOG.md b/neat_cache/CHANGELOG.md index 15e3a8ac..aa5dc563 100644 --- a/neat_cache/CHANGELOG.md +++ b/neat_cache/CHANGELOG.md @@ -1,3 +1,6 @@ +## v2.0.4 + * Reconnect when a redis command fails. + ## v2.0.3 * Added `topics` to `pubspec.yaml`. diff --git a/neat_cache/lib/src/providers/redis.dart b/neat_cache/lib/src/providers/redis.dart index 55b9adef..b5dbf649 100644 --- a/neat_cache/lib/src/providers/redis.dart +++ b/neat_cache/lib/src/providers/redis.dart @@ -131,7 +131,12 @@ class RedisCacheProvider extends CacheProvider> { try { return await fn(ctx.client).timeout(_commandTimeLimit); } on RedisCommandException catch (e) { - throw AssertionError('error from redis command: $e'); + // We don't really know what happened, let's log shout it. + // It could be a sign that something really bad is happening to redis. + // Best shutdown the connection and try again. + _log.shout('Error from redis command: $e'); + await ctx.client.close(force: true); + throw IntermittentCacheException('error from redis command: $e'); } on TimeoutException { // If we had a timeout, doing the command we forcibly disconnect // from the server, such that next retry will use a new connection. diff --git a/neat_cache/pubspec.yaml b/neat_cache/pubspec.yaml index 676e1e08..1837fe43 100644 --- a/neat_cache/pubspec.yaml +++ b/neat_cache/pubspec.yaml @@ -1,5 +1,5 @@ name: neat_cache -version: 2.0.3 +version: 2.0.4 description: >- A neat cache abstraction for wrapping in-memory or redis caches. homepage: https://github.com/google/dart-neats/tree/master/neat_cache