public void Dispose() { Database.ExecuteAsync("FLUSHALL").Wait(); Client.Dispose(); Cluster.StopAllSilos(); _redis?.Dispose(); }
public static Redis CreateRedis(Action <IConfig> configuration) { return(Policy.Handle <Exception>() .WaitAndRetry(new[] { TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(3) }, (exception, timeSpan) => { }) .Execute(() => { Redis instance = null; try { instance = new Redis(configuration); } catch (Exception) { instance?.Dispose(); throw; } return instance; })); }