https://github.com/skillmaker-dev/inmemorycaching_asp.net6
Using In-Memory Cache in ASP.NET 6 and comparing it with no caching.
https://github.com/skillmaker-dev/inmemorycaching_asp.net6
Last synced: 8 months ago
JSON representation
Using In-Memory Cache in ASP.NET 6 and comparing it with no caching.
- Host: GitHub
- URL: https://github.com/skillmaker-dev/inmemorycaching_asp.net6
- Owner: skillmaker-dev
- Created: 2022-10-02T22:28:56.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-10-02T22:37:26.000Z (over 3 years ago)
- Last Synced: 2025-03-23T09:35:21.796Z (11 months ago)
- Language: HTML
- Size: 186 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Using in memory caching in ASP.NET6 and demonstrating it using a Blazor webserver application.
## We have 3 methods to load Employees:
- GetEmployees() : Load data synchronously
- GetEmployeesAsync() : Load asynchronously
- GetEmployeesCached() : Load asynchronously and cached when available
In ```FetchData.razor``` change the method in ```OnInitializedAsync()``` to compare between different data loading ways.
You can see that the first time we load data it will take 3 seconds to be available, Then on the second try, We will get data instantly, This is because we are loading the data from the database in the first time and then saving it to the cache, In the next times we are getting data directly from the memory cache.
#### Note: If your data is changing overtime then don't cache it for too long.