关于‘最近访客’的一些想法
问题描述
最近访客功能记录个人空间被哪些用户访问过
入口问题
进入用户个人空间的入口颇多
如
http://xuliangyong.iteye.comhttp://xuliangyong.iteye.com/blog/342762http://xuliangyong.iteye.com/category/46687http://xuliangyong.iteye.com/blog/pdf
是对所有入口都处理还是有选择的处理 根据自身环境定
写数据库频率
入口确定后 接下来是将访客的id写入数据库
每次访问都写数据库是不现实的,可采用 cookie或session控制写如数据库的频率
逻辑为
if( !existMyCookie ){ writeDB(); writeMyCookie(expireDate);}insert into `sns_user_visitor`(host_id, visitor_id, visit_time) select 34, 35, '2009-1-1' from dual where not EXISTS( select id from `sns_user_visitor` where host_id = 34 and visitor_id=35);