google-code-export / b3log-solo

Automatically exported from code.google.com/p/b3log-solo
0 stars 1 forks source link

在线人数计数问题 #408

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
在 GAE 生产环境上,HttpSessionListener#sessionDestroyed 
是不会被调用的,导致在线人数只增不减。

为了兼容 GAE 和本地容器,考虑不基于 HttpSessionListener 
实现计数维护:

1. 在缓存中维护计数
2. 根据请求 IP 进行计数
3. 记录请求的时间,定时任务清除过期计数

缓存数据结构:"onlineVisitorCount": [{
      "ip": "",
      "recentTime": long
   }, ....]

Original issue reported on code.google.com by dl88250 on 16 May 2012 at 2:18

GoogleCodeExporter commented 9 years ago
为了降低实现复杂度,使用内存 Map。

数据结构:<ip, recentTime>

某 IP 5 分钟内如果没有请求,则认为过期。

Original comment by dl88250 on 16 May 2012 at 3:14

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r4877.

Original comment by dl88250 on 16 May 2012 at 3:32

GoogleCodeExporter commented 9 years ago

Original comment by dl88250 on 16 May 2012 at 9:59