Skip to content

FrankFK/in-memory-cache-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

In Memory Cache Example

My backend needs to collect data. This takes a lot of time, so I don’t want to collect the data with every API call, but instead cache it in memory. The cache should be updated regularly in a background thread. However, it should also be possible to explicitly initiate the update via an API call. How could this be implemented in .NET Core?

This example shows how this could be solved.

You can find further explanations in my blog post Cache data in memory and update it regularly via a background service (.NET Core MinimalAPI example)

Testing

For testing you can open a command line and use curl

curl -s https://localhost:59999/summary/authors
curl -d "" https://localhost:59999/triggerCacheUpdate/authors

The port 59999 must be replaced with the port that Visual Studio entered in file .\InMemCacheMinimalApi\Properties\launchSettings.json after the first startup on your machine.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages