Adds state management and caching to AspireWithDapr Weather sample#29
Open
paulyuk wants to merge 2 commits intomicrosoft:mainfrom
Open
Adds state management and caching to AspireWithDapr Weather sample#29paulyuk wants to merge 2 commits intomicrosoft:mainfrom
paulyuk wants to merge 2 commits intomicrosoft:mainfrom
Conversation
added 2 commits
November 14, 2023 09:57
Signed-off-by: Paul Yuknewicz <[email protected]>
Signed-off-by: Paul Yuknewicz <[email protected]>
| // If it doesn't exist, get it from the weather service | ||
| weatherData = await daprClient.InvokeMethodAsync<WeatherForecast[]>(HttpMethod.Get, apiAppId, "weatherforecast"); | ||
|
|
||
| await daprClient.SaveStateAsync(stateStore, "weather", weatherData, metadata: new Dictionary<string, string>() { |
Member
There was a problem hiding this comment.
Is the metadata parameter typed as Dictionary<string, string>? If so, we can simplify to use target-typed new here. If not, oh well 😄
DamianEdwards
approved these changes
Nov 14, 2023
eerhardt
reviewed
Nov 14, 2023
| return await daprClient.InvokeMethodAsync<WeatherForecast[]>(HttpMethod.Get, "api", "weatherforecast"); | ||
|
|
||
| // Get the weather from the state store if it exists | ||
| var weatherData = await daprClient.GetStateAsync<WeatherForecast[]>(stateStore, "weather"); |
Member
There was a problem hiding this comment.
This app also uses output caching at the UI layer. Does it make sense to use both? Should we remove the output caching and use this instead?
Member
There was a problem hiding this comment.
Oh good point. Technically they're caching at different levels (API response vs. full HTML response) so could still be argued it's valuable.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current sample showcases service invoke + nice treatment of sidecars.
This shows just a bit more around using powerful APIs like state management along with built in integrations with Redis to achieve a better result, simply.