使用缓存提高系统性能
This commit is contained in:
parent
46a626a97e
commit
b0b9491dfe
@ -16,5 +16,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.0.2" />
|
||||
<PackageReference Include="Aspire.Hosting.Redis" Version="8.0.2" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -3,13 +3,15 @@
|
||||
|
||||
var builder = DistributedApplication.CreateBuilder(args);
|
||||
|
||||
var cache = builder.AddRedis("cache", port:6379);
|
||||
|
||||
var identityService = builder.AddProject<Projects.HelloShop_IdentityService>("identityservice");
|
||||
|
||||
var orderingService = builder.AddProject<Projects.HelloShop_OrderingService>("orderingservice").WithReference(identityService);
|
||||
|
||||
var productService = builder.AddProject<Projects.HelloShop_ProductService>("productservice").WithReference(identityService);
|
||||
|
||||
var basketService = builder.AddProject<Projects.HelloShop_BasketService>("basketservice").WithReference(identityService);
|
||||
var basketService = builder.AddProject<Projects.HelloShop_BasketService>("basketservice").WithReference(identityService).WithReference(cache);
|
||||
|
||||
var apiservice = builder.AddProject<Projects.HelloShop_ApiService>("apiservice")
|
||||
.WithReference(identityService)
|
||||
|
@ -13,10 +13,12 @@
|
||||
<Protobuf Include="Protos\greet.proto" GrpcServices="Server" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.StackExchange.Redis.DistributedCaching" Version="8.0.2" />
|
||||
<PackageReference Include="Calzolari.Grpc.AspNetCore.Validation" Version="8.1.0" />
|
||||
<PackageReference Include="Grpc.AspNetCore" Version="2.63.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.7" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Grpc.Swagger" Version="0.8.7" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="8.0.7" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HelloShop.ServiceDefaults\HelloShop.ServiceDefaults.csproj" />
|
||||
|
@ -24,7 +24,7 @@ builder.Services.AddAuthentication().AddJwtBearer(options =>
|
||||
});
|
||||
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
builder.Services.AddDistributedMemoryCache();
|
||||
builder.AddRedisDistributedCache("cache");
|
||||
builder.Services.AddSingleton<IBasketRepository, DistributedCacheBasketRepository>();
|
||||
|
||||
builder.Services.AddGrpc(options => options.EnableMessageValidation()).AddJsonTranscoding();
|
||||
|
Loading…
Reference in New Issue
Block a user