Skip to content

Commit

Permalink
Preview 7 changes (#33340)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdykstra authored Aug 13, 2024
1 parent 34a5705 commit 28a78a8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Hybrid" Version="9.0.0-preview.6.24328.4" />
<PackageReference Include="Microsoft.Extensions.Caching.Hybrid" Version="9.0.0-preview.7.24406.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,8 @@ public static void Main(string[] args)

app.UseAuthorization();

app.MapGet("/{name}/{ID}", async (context) =>
app.MapGet("/{name}/{ID}", async (HttpContext context, string? name, Int32 ID) =>
{
string? name = context.Request.RouteValues["name"] as string;
int ID = Convert.ToInt32(context.Request.RouteValues["ID"]);
var someService = context.RequestServices.GetRequiredService<SomeService>();
var someInfo = await someService.GetSomeInfoAsync(name!, ID);
context.Response.StatusCode = 200;
Expand All @@ -79,7 +76,7 @@ public async Task<string> GetSomeInfoAsync(string name, int id, CancellationToke
return await _cache.GetOrCreateAsync(
$"{name}-{id}", // Unique key to the cache entry
async cancel => await GetDataFromTheSourceAsync(name, id, cancel),
token: token
cancellationToken: token
);
}

Expand Down Expand Up @@ -110,7 +107,7 @@ public async Task<string> GetSomeInfoAsync(string name, int id, CancellationToke
async cancel => await GetDataFromTheSourceAsync(name, id, cancel),
entryOptions,
tags,
token: token
cancellationToken: token
);
}

Expand All @@ -135,7 +132,7 @@ public async Task<string> GetSomeInfoAsync(string name, int id, CancellationToke
(name, id, obj: this),
static async (state, token) =>
await state.obj.GetDataFromTheSourceAsync(state.name, state.id, token),
token: token
cancellationToken: token
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.0-preview.6.24328.4" />
<PackageReference Include="Microsoft.Extensions.Caching.SqlServer" Version="9.0.0-preview.6.24328.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0-preview.6.24327.7" />
<PackageReference Include="Microsoft.Extensions.Caching.Hybrid" Version="9.0.0-preview.6.24328.4" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.0-preview.7.24406.2" />
<PackageReference Include="Microsoft.Extensions.Caching.SqlServer" Version="9.0.0-preview.7.24406.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0-preview.7.24406.2" />
<PackageReference Include="Microsoft.Extensions.Caching.Hybrid" Version="9.0.0-preview.7.24406.2" />
<PackageReference Include="Google.Protobuf" Version="3.26.1" />
<PackageReference Include="Grpc.Tools" Version="2.63.0" />
<PackageReference Include="Grpc.Core" Version="2.46.6" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@ public static void Main(string[] args)

app.UseAuthorization();

app.MapGet("/{ID}", async (context) =>
app.MapGet("/{ID}", async (HttpContext context, Int32 ID) =>
{
int ID = Convert.ToInt32(context.Request.RouteValues["ID"]);
var someService = context.RequestServices.GetRequiredService<SomeService>();
var someProtobufMessage = await someService.GetSomeProtobufMessageFromCacheAsync(ID);
var someMessage = await someService.GetSomeMessageFromCacheAsync(ID);
Expand Down Expand Up @@ -138,7 +136,7 @@ public async Task<SomeMessage>
return await _cache.GetOrCreateAsync(
$"SomeMessage_{id}", // Unique key to the cache entry
async cancel => await GetSomeMessageFromSourceAsync(id, token),
token: token
cancellationToken: token
);
}

Expand All @@ -148,7 +146,7 @@ public async Task<SomeProtobufMessage>
return await _cache.GetOrCreateAsync(
$"Protobuf_{id}", // Unique key to the cache entry
async cancel => await GetSomeProtobufMessageFromSourceAsync(id, token),
token: token
cancellationToken: token
);
}

Expand Down

0 comments on commit 28a78a8

Please sign in to comment.