From b0b9491dfe5c71ddaa71706339cef6aa138255b6 Mon Sep 17 00:00:00 2001 From: hello Date: Sat, 13 Jul 2024 09:59:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=BC=93=E5=AD=98=E6=8F=90?= =?UTF-8?q?=E9=AB=98=E7=B3=BB=E7=BB=9F=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/HelloShop.AppHost/HelloShop.AppHost.csproj | 1 + src/HelloShop.AppHost/Program.cs | 4 +++- src/HelloShop.BasketService/HelloShop.BasketService.csproj | 2 ++ src/HelloShop.BasketService/Program.cs | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/HelloShop.AppHost/HelloShop.AppHost.csproj b/src/HelloShop.AppHost/HelloShop.AppHost.csproj index 0b4dd96..0d68099 100644 --- a/src/HelloShop.AppHost/HelloShop.AppHost.csproj +++ b/src/HelloShop.AppHost/HelloShop.AppHost.csproj @@ -16,5 +16,6 @@ + \ No newline at end of file diff --git a/src/HelloShop.AppHost/Program.cs b/src/HelloShop.AppHost/Program.cs index fdef62a..fe936b5 100644 --- a/src/HelloShop.AppHost/Program.cs +++ b/src/HelloShop.AppHost/Program.cs @@ -3,13 +3,15 @@ var builder = DistributedApplication.CreateBuilder(args); +var cache = builder.AddRedis("cache", port:6379); + var identityService = builder.AddProject("identityservice"); var orderingService = builder.AddProject("orderingservice").WithReference(identityService); var productService = builder.AddProject("productservice").WithReference(identityService); -var basketService = builder.AddProject("basketservice").WithReference(identityService); +var basketService = builder.AddProject("basketservice").WithReference(identityService).WithReference(cache); var apiservice = builder.AddProject("apiservice") .WithReference(identityService) diff --git a/src/HelloShop.BasketService/HelloShop.BasketService.csproj b/src/HelloShop.BasketService/HelloShop.BasketService.csproj index f555e61..6aea2ac 100644 --- a/src/HelloShop.BasketService/HelloShop.BasketService.csproj +++ b/src/HelloShop.BasketService/HelloShop.BasketService.csproj @@ -13,10 +13,12 @@ + + diff --git a/src/HelloShop.BasketService/Program.cs b/src/HelloShop.BasketService/Program.cs index e0f29d5..2c2235d 100644 --- a/src/HelloShop.BasketService/Program.cs +++ b/src/HelloShop.BasketService/Program.cs @@ -24,7 +24,7 @@ builder.Services.AddAuthentication().AddJwtBearer(options => }); builder.Services.AddHttpContextAccessor(); -builder.Services.AddDistributedMemoryCache(); +builder.AddRedisDistributedCache("cache"); builder.Services.AddSingleton(); builder.Services.AddGrpc(options => options.EnableMessageValidation()).AddJsonTranscoding();