Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8847459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:11:42+00:00 2026-06-14T12:11:42+00:00

The 3 commands below work perfectly when they are executed as is. using (var

  • 0

The 3 commands below work perfectly when they are executed as is.

using (var redis = NewRedisConnection)
{
    await redis.Open();
    var allKeys = await redis.Keys.Find(db, "searchPattern");
    var allVals = await redis.Strings.GetString(db, allKeys);
    await redis.Keys.Remove(db, allKeys);

    //process the data I pull from redis
}

But when I try to wrap them in a transaction it stops working. Exceptions aren’t thrown, but if I debug the execution seems to stop at var allKeys = ... Am I missing something While setting up the transaction?

using (var redis = NewRedisConnection)
{
    await redis.Open();
    var tran = redis.Createtransaction();

    var allKeys = await tran.Keys.Find(db, "searchPattern");
    var allVals = await tran.Strings.GetString(db, allKeys);
    await tran.Keys.Remove(db, allKeys);

    await tran.Execute();
    //process the data I pull from redis
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:11:43+00:00Added an answer on June 14, 2026 at 12:11 pm

    Transactions are buffered locally until you call “exec”, which is then sent in an atomic unit. If you “await” before the exec, you’ll never send anything. It is necessary to only “await” the operations in a transaction only after execute is called.

    Secondly, you cannot query data during a transaction. To be more specific, you can, but you only get the results when you call “execute”. This is a fundamental part of how redis works: simply, a redis transaction is not the same as a SQL transaction. This means you can’t make decisions based on data queried during a transation. You can, however, query the data outside the transaction, and then ensure it doesn’t change. With booksleeve, the AddConstraint method on a transaction can add a number of common assertions which can be safely validated during the transaction.

    Thirdly, Keys.Find should not be used as part of routine code – that should be used rarely, typically during debug and database analysis.

    In your case, I wonder whether a “hash” would be a better option – so rather than “find all keys matching this pattern, fetch all values from those keys, delete all those keys”, it could be done as “get all values from this hash, delete this hash”.

    so something like (note: mobile phone code! Excuse typos)

    using(var tran = conn.CreateTransaction())
    {
        valsPending = tran.Hashes.GetAll(db, key);
        tran.Keys.Remove(db, key);
        await tran.Execute();
        var vals = await valsPending;
        // iterate dictionary in "vals", decoding each .Value with UTF-8
    }
    

    I can add a GetAllString if it makes the above easier.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have downloaded mysql-connector-c-6.0.2. I build it using below commands: cmake -G Unix Makefiles
I have these Vim mappings for Git. Most of the commands below work, but
I have implemented the cancan with active_admin using below link. https://github.com/gregbell/active_admin/wiki/How-to-work-with-cancan Just in my
1- what is the performance difference of below commands? ... Where ID in (1,2,3)
How would i add key commands to the sprite plumbers? Below is my attempt
All the code/commands below are part of a PHP script that processes images from
Below is a php code i made in a non codeigniter code work. It
I've inserted some shell commands into python script like below: #!/usr/bin/python import os,sys,re import
I am trying to Execute a multiple commands in php using exec() and shell_exec
I have a powershell script (below) which seems to work but prints an error

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.