[英]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. 这里的高级问题-我正在开发一个Spring MVC / Spring Data Project,以通过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. 在整个应用程序使用过程中,我都希望保留List
中的这些记录,直到满足重置或删除List
的条件为止。
My question is, is it feasible to store this List
in my HttpSession
? 我的问题是,将此List
存储在我的HttpSession
是否可行?
List
in the session? 如果将我的List
存储在会话中,是否存在安全问题? A quick view of the user session info along side a small List of 4 objects (could potentially be thousands) 快速查看用户会话信息以及4个对象的小型列表(可能是数千个)
Session Attribute Name Session Attribute Value
searchResults [com.mysite.dto.User@322bfb87,
com.mysite.dto.User@658e75cc,
com.mysite.dto.User@6bd7d82a,
com.mysite.dto.User@27b0e4b6]
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). 您可以使用外部缓存,例如BigMemory Terracotta( http://terracotta.org/products/bigmemory )或memcache(如果您在EC2中运行应用程序,Amazon提供了一种易于使用的缓存)。 This will be much more scale able than your servers JVM heap. 这将比您的服务器JVM堆具有更大的扩展能力。
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. 另一个想法是将用户ID与用户对象的引用存储在缓存中,现在在会话中您只能存储ID。 That way your session saves only numbers instead of whole objects 这样,您的会话仅保存数字,而不是整个对象
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.