PHP,在将数据存储到会话和数据库之间的更好方法是什么? [英] PHP, which is the better way between storing data into session and database?
问题描述
我正在建立一个网站,向用户显示推荐页面.
I am building a website that shows recommend pages for users.
用户只需单击下一步"按钮即可查看不同的推荐网页.
Users only click next button to look at different recommend web pages.
我想检查用户可以进行的每一项活动.
I wanna check every single activities that users can make.
因此,我将检查用户实际看到的页面浏览量.
So, I will check page views that users actually see.
1. there is a 'user_pageview' column for each users.
2. the numbers will increase every time if users click next button.
我可以每次发送查询以更新数据.
I can send a query to update data every single time.
但是,我认为此步骤会让我的服务器烦恼.
However, I believe this step will be annoying to my server.
因此,我正在考虑将数据保存到会话中一段时间,然后再保存.
So, I am thinking to save the data into session for a while and save it later.
您怎么看?
推荐答案
是的,这将烦扰您的服务器".
同样,您也可以通过骑车烦死"汽车.
Yes it will be "annoying your server".
The same way you are "annoying" your car by riding it.
数据库服务器的目的是操作数据-存储,检索,过滤等.
在数据库中存储数据基本上没有错误.
A database server's intention is to operate the data - store, retrieve, filter, etc.
There is nothing essentially wrong with storing data in the database.
是的,可能是索引重建(如果有)的问题.
但是,跟踪用户会话也会出现问题.
There may be a problem, yes, with index rebuilding (if any).
However, there would be a problem with tracking user session too.
因此,直到我对数据库有某些问题(这极有可能永远不会发生)之前,我不会理会会话.
So, I won't bother with session until I have certain problem with database (which most likely won't occur ever).
这篇关于PHP,在将数据存储到会话和数据库之间的更好方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!