Skip to content

Commit

Permalink
doc: recipe for ef core
Browse files Browse the repository at this point in the history
  • Loading branch information
titouancreach committed Mar 9, 2023
1 parent 0b3e6dd commit 484da69
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ You can name the consumer with the third parameter of `AddRedisStreamBackgroundR
When multiple consumer are subscribed to the same event, or when, there is multiple event pending, they are executed concurrently.
This mean that you should not rely of the order they are inserted.

To avoid any concurrency issues, **consumers should be registered as Transient**. So, if you use Entity Framework, register it as Transient too:

```cs
builder.Services.AddDbContext<ApplicationDbContext>(options =>
SqlServerDbContextOptionsExtensions.UseSqlServer(options, dbConn), ServiceLifetime.Transient);
```

### Reccuring tasks

You can add a Redis Hash in a special named key: `Cron:Schedule:{Name of your cron}`. This hash should have as a fields (in the order bellow):
Expand Down

0 comments on commit 484da69

Please sign in to comment.