-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from PandaTechAM/development
Added redis and signalR utils
- Loading branch information
Showing
9 changed files
with
115 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using DistributedCache.Extensions; | ||
using DistributedCache.Options; | ||
using Microsoft.AspNetCore.Builder; | ||
|
||
namespace SharedKernel.Extensions; | ||
|
||
public static class DistributedCacheExtension | ||
{ | ||
public static WebApplicationBuilder AddRedis(this WebApplicationBuilder builder, KeyPrefix keyPrefix) | ||
{ | ||
builder.AddDistributedCache(options => | ||
{ | ||
options.RedisConnectionString = builder.Configuration.GetRedisUrl(); | ||
options.KeyPrefixForIsolation = keyPrefix; | ||
}); | ||
|
||
return builder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using StackExchange.Redis; | ||
|
||
namespace SharedKernel.Extensions; | ||
|
||
public static class SignalRExtensions | ||
{ | ||
|
||
public static WebApplicationBuilder AddSignalR(this WebApplicationBuilder builder) | ||
{ | ||
builder | ||
.Services | ||
.AddSignalR() | ||
.AddMessagePackProtocol(); | ||
|
||
return builder; | ||
} | ||
|
||
public static WebApplicationBuilder AddDistributedSignalR(this WebApplicationBuilder builder, string redisChannelName) | ||
{ | ||
builder | ||
.Services | ||
.AddSignalR() | ||
.AddMessagePackProtocol() | ||
.AddStackExchangeRedis(builder.Configuration.GetRedisUrl(), | ||
options => | ||
{ | ||
options.Configuration.ChannelPrefix = RedisChannel.Literal("FinHub:SignalR:"); | ||
}); | ||
|
||
|
||
return builder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters