Firstly, I persist the portraits (images) of all users in the db as Strings (large one, say length 5000). Then, I want to get the
String and display the portraits of users on the web page(like a topic in a forum). Here I know three solutions but none of them is efficient:
1. Because the image is large, it's not efficient to store it in objects(beans).
2. Because I have many users(say 300), if I store all the maps(userId and image) in the session, the session will be huge.
3. Because I have many users(say 300), if I access the db for each user's image, the worse case is I will have to access db for 300 times.
Is there any solution (such as a design
pattern or interceptor) for this performance issue? Many thanks!