使用PHP $ _SESSION变量存储大量数据 [英] Using PHP $_SESSION variable to store large amonts of data
问题描述
我目前在$ _SESSION变量中存储了大量数据.我正在这样做,所以我不需要继续访问数据库.
I'm currently storing a fair amount of data in the $_SESSION variable. I'm doing this so I don't need to keep accessing the database.
我应该担心共享服务器上的内存问题吗?
Should I be worried about memory issues on a shared server?
服务器可以处理$ _SESSION变量中存储的大量数据吗?
Can servers cope with large amounts of data stored in the $_SESSION variable?
推荐答案
我应该担心共享服务器上的内存问题吗?
Should I be worried about memory issues on a shared server?
是-每次请求都将会话数据加载到脚本的内存中.因此,您有打破单个脚本存储限制的风险.即使您没有达到极限,这实际上也没有效率.
Yes - session data is loaded into the script's memory on every request. Hence, you are at risk of breaking the individual per-script memory limit. Even if you don't hit the limit, this is really inefficient.
按需访问数据库的数据要好得多..
Accessing data from the database on demand is much better.
这篇关于使用PHP $ _SESSION变量存储大量数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!