Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Transaction for Redis Stack Commands #78

Closed
shacharPash opened this issue Jan 31, 2023 · 6 comments · Fixed by #79 or #68
Closed

Implement Transaction for Redis Stack Commands #78

shacharPash opened this issue Jan 31, 2023 · 6 comments · Fixed by #79 or #68

Comments

@shacharPash
Copy link
Contributor

similar to pipelines (#50).
with MULTI and EXEC.

@Jeevananthan-23
Copy link
Contributor

 public class Transactions
    {
        public Transactions(IConnectionMultiplexer muxer)
        {
            _transaction = muxer.GetDatabase().CreateTransaction();
        }

        public Transactions(IDatabase db)
        {
            _transaction = db.CreateTransaction();
        }

        private ITransaction _transaction;

        public void AddCondition(Condition condition)
        {
            _transaction.AddCondition(condition);
        }

        public void Execute()
        {
            _transaction.Execute();
        }

        public void ExecuteAsync()
        {
            _transaction.ExecuteAsync();
        }
    }

@shacharPash does this helps?

@shacharPash
Copy link
Contributor Author

Yes 👍
Do you want to send it as a PR or will I take it?
We need to add tests and maybe some more changes to support all the modules.

@Jeevananthan-23
Copy link
Contributor

Jeevananthan-23 commented Jan 31, 2023

I'll work on the PR.

Yes 👍 Do you want to send it as a PR or will I take it? We need to add tests and maybe some more changes to support all the modules.

Do modules support only Async?

@shacharPash
Copy link
Contributor Author

I'll work on the PR.

Yes 👍 Do you want to send it as a PR or will I take it? We need to add tests and maybe some more changes to support all the modules.

Do modules support only Async?

Any command has Sync and Async version.
for example:
Json.Set - Sync
Json.SetAsync - Async

When you use Pipelines or Transaction, you only has access to the async methods - because the result of
each operation will not be known until after Execute (or ExecuteAsync) has completed.

@Jeevananthan-23
Copy link
Contributor

@shacharPash #79 was created for drafted one transaction support and should add some more tests

@Jeevananthan-23
Copy link
Contributor

Condition class does not support any redis modules

[Fact]
   public void TransactionExample()
   {
       var tran = new Transactions(ConnectionMultiplexer.Connect("localhost"));

       tran.AddCondition(Condition.HashNotExists("profesor:5555", "first")); // Condition class 
       tran.Db.HashSetAsync("profesor:5555", new HashEntry[] { new("first", "Albert"), new("last", "Blue"), new("age", "55") });
       var condition = tran.ExecuteAsync();
       Assert.True(condition.Result);
   }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants