We're using Blazor (Server Side) and .NET 5 for a new solution which requires use of session to eliminate round trips to the DB for the exact same data.
We're currently using the recommended ProtectedBrowserStorage model but we ran into the 25MB limitation of the browser when we tried to store a relatively large dataset. So this may not be ideal when we're dealing with many 1000's of records that need to be viewed and manipulated by the end user. We're trying to optimize performance for end users. This is a connected Desktop scenario.
Is there a better way to handle large session variables in Blazor that isn't limited by the client browser?
Thanks in advance.
CodePudding user response:
to eliminate round trips to the DB for the exact same data.
You could use Caching. That allows sharing data between Sessions/Users (could be a risk, just be careful). It will also reduce I/O.
Caching is server-side and that's where your app runs too. So it wil be generally faster. But it's not clear what your memory constraints (per user) are.
CodePudding user response:
You can use IndexedDb that is supported in all major browsers.
I use this object store db in a PWA but you can use it with a Blazor Server side app or a Blazor WASM client app.
The limit of an IndexedDB aren't a problem for your and for mostly any situation.
The browser manages the data and you only need to decide your policy on how to refresh them.
Start from this library https://github.com/amuste/DnetIndexedDb and try some samples.
CodePudding user response:
There are a few different ways you can do this depending on your needs:
Cascading Parameters: A good video for the basics of it - https://www.youtube.com/watch?v=ZmDMKp1Q8kA
An AppState approach: A good video for it covering two different ways: https://www.youtube.com/watch?v=BB4lK2kfKf0
The main issue with both of these is they are still by session and will be gone on refresh or a new tab.
The only other solution I know of is by using redis, this would keep the data as long as you want to keep it for but it would not be in blazor. Good video of it: https://www.youtube.com/watch?v=UrQWii_kfIE
CodePudding user response:
It depends on how many concurrent users you have, and your system resources.
A singleton service persists across sessions, and you can use whatever data structures you want.