Storing in Session versus retrieving from database
I'm very interested to hear the SO community opinion and recommended practice for this.
I currently have an ASP MVC application that validates a set of开发者_StackOverflow社区 rules (~100 rows (classes with 10 properties)) every time a user fills out a short form. There are about 10 forms in the application and there are rarely ever more than 3 concurrent users on the application.
Currently I am storing all the rules in the Session variable that loads initially and is persisted throughout the forms. Is this too much or bad practice to store in memory? I did this to speed up the application, the load is pretty quick (less than a second) so I'm debating just loading as needed per form.
So - keep the rules table in memory (session variable) or load when validating each form?
there are rarely ever more than 3 concurrent users on the application
That means you could store quite a lot in the session.
Your approach just doesn't 'scale' very well, that's why common wisdom will argue against it. But as long as your '3' doesn't become '300' or '3000', you're safe.
精彩评论