3

如何显示一份报告,显示所有当前的海滨会议及其预期到期时间?

self session application sessionsDo: [:each | 
html text: 'Session For ',((each properties values at: 1) username),' Expires At: '.
html render: (Time now addSeconds: (each application cache expiryPolicy timeout)).
html break].

但是,这显示了错误的结果,因为它显示所有会话同时到期,即距现在时间 600 秒。我找不到另一种方法来获得“剩余时间”。

世界末日?(卢卡斯会做什么)?

KR 尘土飞扬

4

1 回答 1

7

下面的代码应该做到这一点:

WAApplication allInstances do: [ :application |
   application keysAndHandlersDo: [ :key :session |
      | policy table |
      policy := application cache expiryPolicy.
      table := policy instVarNamed: 'lastAccessTable'.
      Transcript 
        show: session; show: ' expires in '; 
        show: policy timeout - (Time totalSeconds - (table at: key));
        show: ' seconds'; cr ] ]

请注意,上述代码访问的内部数据结构将来可能会发生变化。此外,您可能需要添加额外的检查以使其适用于您的设置。

另请注意,您可能会得到负秒数。这意味着会话应该消失,但尚未收获。

于 2012-11-27T12:23:04.450 回答