From the course: .NET Microservices for Azure Developers
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Solution: Implement a new endpoint and memory cache - Azure Tutorial
From the course: .NET Microservices for Azure Developers
Solution: Implement a new endpoint and memory cache
(upbeat music) - [Instructor] Let me show you how I solved the challenge. First, in the pets controller class, I added this update method that is receiving a pet update object. And this is a record that has the name, the age, and their breed ID, and I'm searching for that particular pet in the DB context. And of course, I'm validating if the pet exists, in which case I'm updating the name, the age, and the breed ID, and then saving the changes back to the DB context. Then, in the clinic application service class, I'm injecting IMemoryCache and I'm using it's get or create async method for storing the pet info object. And you can see that I'm using absolute expiration relative to now in 30 seconds. In other words, the object will be refreshed in the cache every 30 seconds. In the meantime, if you send a request, then the clinic microservice is going to use the object from the cache. And finally, here in the program class, I'm invoking add memory cache, which is the default…
Contents
-
-
-
-
-
-
-
(Locked)
Creating the Clinic microservice2m 44s
-
(Locked)
Adding the ClinicDbContext class3m 44s
-
(Locked)
Implementing the ManagementService class5m 41s
-
(Locked)
Implementing the ClinicApplicationService class6m 35s
-
(Locked)
Adding resilience traits to the microservice using Polly3m 20s
-
(Locked)
Creating the Container App for the Clinic microservice1m 2s
-
(Locked)
Creating the Dockerfile and modifying the workflow3m 17s
-
(Locked)
Adding environment variables to the Clinic microservice4m 41s
-
(Locked)
Challenge: Implementing a new endpoint and memory cache1m 30s
-
(Locked)
Solution: Implement a new endpoint and memory cache2m 41s
-
(Locked)
-