Reputation: 113
I am working on a web application that is consuming a Dataset returned by a web service.
As the application is running I store that Dataset as a session variable to be used over and over again as the user navigates to the different pages that will edit the tables within the dataset.
The idea was the user will only have to wait for the data once when the application loads then the application would use the session variable until the user saves the changes they made, when that happens it would pass the edited tables to the service to update the database.
Is there problems with this design and the storage of the Dataset and Datatables as a session variable? Pros and Cons let me know.
Upvotes: 5
Views: 2671
Reputation: 6440
The only pro is:
The cons are legion but the main three would be:
[Edit] As others have pointed out, there is also a problem with saving anything in Session or Cache (or to a lesser extent Application) without persisting it somewhere more permanent as well. If a Session expires, or even resets itself (I have seen hardware configurations that cause the Session to begin and end with every request. Though it retains the Session ID, any data stored in Session objects is lost. If the Application is restarted for whatever reason, all of the Session, Cache and Application objects are cleared down. Cache objects can clear theselves at any time, just because the environment decides it wants that memory space for something else.
In summary: This is not the way to go.
If you need the user to be able to make changes and then hit Save to persist them, keep a separate set of State tables that detail the changes that should be made to the main tables when the user hits Save. Store a cookie on the client with a key which expires a long way into the future; use that cookie to match your State data to the User.
Upvotes: 6
Reputation: 9185
Is the data specific to the user ? If not then you end up storing "no. users logged in " times the datatable. May be you can use some kind of cache mechanism, if you are bothered about the latency.
Upvotes: 0
Reputation: 116937
Keeping too much in the session has the risks that:
If you have to store something in the session, to do what you described maybe consider a specific type for this purpose instead of a generic Dataset or DataTable.
Upvotes: 4
Reputation: 11874
Big con: DataSets are huge, so keeping all of them in the server memory is a problem, specially when the number of users starts to grow.
Upvotes: 3