Is storing List of 1000+ instance of my custom class in session a memory problem?
Is s开发者_运维百科toring a list of 1000 instance of my custom class to the session variable a good approach ? My asp.net web app need multilingual support and i am storing the labels in a table.I will have multiple users who has their own language preference and text(label content) preference.
I am thinking about loading the labels and store it in session variable and access that to use in the pages.Storing it in Application variable does not work because each customer have their own text for the labels.So is storing session a good way of doing this ? I guess i will have almost 1000 labels as of now and it may increase as the application grows.
My custom class has 2 proprties. LanguageCode and LanguageName
for some reason i cant use asp.net Resource files :(
Whats your thoughts on this ?
You should store a single set of labels for each language, then store the language name in session and use it to look up the correct labelset.
Some thoughts to notice:
If your managers have something in particular against resx's, you can store all those labels in any other format (e.g. plain text files), or in a DB.
If you have little amount of users, and loading time is extremely crucial, your managers may have a point. Other than that, they're wrong, and I would consider trying to explain that to them.
Try considering "computing" the labels at runtime (e.g. if some of them include adding prefixes, suffixes, etc. you can save only the "stems" and provide a relevant label only on demand. That will save you some server space).
If I were you I'd first spend some time trying to figure out why your resource files are not working... as long as you are setting the Thread.CurrentThread.CurrentCulture (or is it CurrentUICulture?) value to the specific culture, and have the resource files in the correct place, I can't think of any reasons as to why it wouldn't work.
Not a good idea, there are two problems with it:
- It will use up the memory on the server, and reduce the number of users that can use the system
- The time for each request will increase
The standard way to do this is using RESX (resource) files. You should try to fix that.
Why not use Application variable and create as many Application variables as the languages you have. Each application variable will be a superset of all the labels for that language.
Or maybe store the entire table(s) in application variable(s), instead of storing multiple session variables that, I assume, they intersect with each other.
精彩评论