StackExchange / StackExchange/StackExchange.Redis

Transaction over multiple Databases

Open
#2,416 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
6.2k
Forks
1.6k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

Hi,

i want to split my datas in multiple Databases.
To keep it safe i want to add or delete datas only in an transaction.

I found multiple code snippet like this:

using var con= await ConnectionMultiplexer.ConnectAsync("127.0.0.1:6379");
var tran= con.CreateTransaction();

var db1= con.GetDatabase(1);
var db2= con.GetDatabase(2);

... Add or Delete on db1 and db2

await tran.ExecuteAsync();

But there is no function CreateTransaction on the ConnectionMultiplexer object. This function is only available on the IDatabase but here i need to set the ID of the database. I think the transaction is only available on the single Database and not on all other.

Here is my Code. How can i add an transaction to keep it safe?

using var con = await ConnectionMultiplexer.ConnectAsync("127.0.0.1:6379");

var db1= con.GetDatabase(1);
var db2= con.GetDatabase(2);

... Add or Delete on db1 and db2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ConnectionMultiplexer, GetDatabase, and CreateTransaction in the issue's example, then review the Redis transaction behavior relevant to database IDs. Determine whether operations on db1 and db2 can be covered by one transaction and document the supported outcome for the provided code.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, redis
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.