View settings.json
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
{ | |
"$help": "https://aka.ms/terminal-documentation", | |
"$schema": "https://aka.ms/terminal-profiles-schema", | |
"actions": | |
[ | |
{ | |
"command": "paste", | |
"keys": "ctrl+v" | |
}, | |
{ |
View Microsoft.PowerShell_profile.ps1
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
oh-my-posh init pwsh --config "https://gist.github.com/nishanc/2a574ff608ac7c6164e31a2eaae7f483#file-nishan-posh-config-json" | Invoke-Expression | |
Import-Module -Name Terminal-Icons | |
Import-Module -Name PSReadLine | |
Set-PSReadLineOption -PredictionSource History | |
Set-PSReadLineOption -PredictionViewStyle ListView | |
Set-PSReadLineOption -EditMode Windows |
View nishan-posh-config.json
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
{ | |
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", | |
"blocks": [ | |
{ | |
"alignment": "left", | |
"segments": [ | |
{ | |
"foreground": "#21c7c7", | |
"style": "plain", | |
"template": "\u256d\u2500", |
View HomeController.cs
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
using Microsoft.Extensions.Caching.Distributed; | |
namespace RedisOnDotnet6Demo.Controllers | |
{ | |
public class HomeController : Controller | |
{ | |
private IDistributedCache _cache; | |
public HomeController(IDistributedCache cache) | |
{ |
View UserRepository.cs
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
public async Task<List<User>> GetUsersAsync() | |
{ | |
List<User> output = new() | |
{ | |
new() { FirstName = "William", LastName = "Jackson" }, | |
new() { FirstName = "Maria", LastName = "Moody" }, | |
new() { FirstName = "Sarah", LastName = "King" }, | |
new() { FirstName = "Gregory", LastName = "Estrada" }, | |
new() { FirstName = "Juan", LastName = "Russell" }, | |
new() { FirstName = "James", LastName = "Bryant" }, |
View HomeController.cs
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
public async Task<IActionResult> Index() | |
{ | |
List<User>? users; | |
string recordKey = $"Users_{DateTime.Now:yyyyMMdd_hhmm}"; | |
users = await _cache.GetRecordAsync<List<User>>(recordKey); // Get data from cache | |
if (users is null) // Data not available in the Cache | |
{ | |
users = await _userRepository.GetUsersAsync(); // Read data from database |
View CacheHelper.cs
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
public static class CacheHelper | |
{ | |
public static async Task SetRecordAsync<T>(this IDistributedCache cache, | |
string recordId, | |
T data, | |
TimeSpan? absoluteExpireTime = null, | |
TimeSpan? slidingExpireTime = null) | |
{ | |
var options = new DistributedCacheEntryOptions(); |
View appsettings.json
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
{ | |
"Logging": { | |
"LogLevel": { | |
"Default": "Information", | |
"Microsoft.AspNetCore": "Warning" | |
} | |
}, | |
"AllowedHosts": "*", | |
"ConnectionStrings": { | |
"Redis": "localhost:5002" |
View Program.cs
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
builder.Services.AddStackExchangeRedisCache(options => { | |
options.Configuration = builder.Configuration.GetConnectionString("Redis"); | |
options.InstanceName = "RedisDemo_"; | |
}); |
View UnnecessaryJoinsBenchmark.cs
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
[MemoryDiagnoser] | |
public class UnnecessaryJoinsBenchmark : Benchmark | |
{ | |
[Benchmark] | |
public async Task<List<CustomView>> WithJoins() | |
{ | |
var books = await (from authors in Context.Authors | |
where authors.Id > 5 | |
join book in Context.Books on authors.Id equals book.AuthorId select book) |
NewerOlder