init method

  1. @override
Future<void> init()
override

Initializes the database service.

Implementation

@override
Future<void> init() async {
  final configurationPath = _generateConfigurationFile();
  _connection = RedisConnection();
  try {
    _command = await _connection.connect(_redisHost, _redisPort);
  } on SocketException catch (_) {
    final process = await Process.start(
      'redis-server',
      [configurationPath.path],
      mode: ProcessStartMode.detached,
    );
    Logger.v('Redis started with PID ${process.pid}');

    /// assumption: redis would fire up within this delayed duration
    await Utils.delay500ms();
    _command = await _connection.connect(_redisHost, _redisPort);
  }

  _command.pipe_start();
}