当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Storing Large Amount of Data in Session - Should I Do This?

问题描述:

High level question here - I am developing a Spring MVC/Spring Data Project to search Tables in a database via Spring Repositories. The tables I am searching on will contain thousands, if not tens of thousands of records. I would like to hold onto these records in a List throughout the duration of using the application, until a condition is met where the List will be reset or removed.

My question is, is it feasible to store this List in my HttpSession?

  • Should I expect any performance issues with this method?
  • Is there a security concern if storing my List in the session?
  • Are there any best practices anyone can offer for a task such as this?

A quick view of the user session info along side a small List of 4 objects (could potentially be thousands)

Session Attribute Name Session Attribute Value

searchResults [[email protected],

[email protected],

[email protected],

[email protected]]

userRoles [ROLE_ADMIN]

username admin

Thanks in advance

网友答案:

i would store them in a cache but not in session. You can use external caches like BigMemory Terracotta (http://terracotta.org/products/bigmemory) or memcache (Amazon provides an easy to use one if you are running your application in the EC2). This will be much more scale able than your servers JVM heap.

another idea would be to store in cache a reference of the user id with the user object and now in session you can store only the ids. That way your session saves only numbers instead of whole objects

分享给朋友:
您可能感兴趣的文章:
随机阅读: