public RedisSagaRepository(Func <IDatabase> redisDbFactory, bool optimistic = true, TimeSpan?lockTimeout = null, TimeSpan?lockRetryTimeout = null,
                                   string keyPrefix = "")
        {
            var options = new RedisSagaRepositoryOptions <TSaga>(optimistic ? ConcurrencyMode.Optimistic : ConcurrencyMode.Pessimistic, lockTimeout, null,
                                                                 keyPrefix);

            var consumeContextFactory = new RedisSagaConsumeContextFactory <TSaga>();

            _repositoryContextFactory = new RedisSagaRepositoryContextFactory <TSaga>(redisDbFactory, consumeContextFactory, options);

            _repository = new SagaRepository <TSaga>(_repositoryContextFactory);
        }
        public static ISagaRepository <TSaga> Create(Func <IDatabase> redisDbFactory, bool optimistic = true, TimeSpan?lockTimeout = null, TimeSpan?
                                                     lockRetryTimeout = null, string keyPrefix = "", TimeSpan?expiry = null)
        {
            var options = new RedisSagaRepositoryOptions <TSaga>(optimistic ? ConcurrencyMode.Optimistic : ConcurrencyMode.Pessimistic, lockTimeout, null,
                                                                 keyPrefix, SelectDefaultDatabase, expiry);

            var consumeContextFactory = new SagaConsumeContextFactory <DatabaseContext <TSaga>, TSaga>();

            var repositoryContextFactory = new RedisSagaRepositoryContextFactory <TSaga>(redisDbFactory, consumeContextFactory, options);

            return(new SagaRepository <TSaga>(repositoryContextFactory));
        }