使用自定义 SessionStateStoreProvider 清理过期会话
我正在使用无模式数据库实现我自己的 SessionStateStoreProvider 。从文档中很难看出,但似乎我必须有一个单独的过程来清理过期的会话,因为数据库无法通知会话状态存储会话已过期。
我这件事有错吗?我还没有看到替代 SetItemExpireCallback 方法的示例。
I'm implementing my own SessionStateStoreProvider with a schemaless database. It's a little hard to tell from the documentation but it seems as though I will have to have a separate process for cleaning up expired sessions since the database will not have a way to notify the session state store that a session has expired.
Am I wrong about this? I haven't seen an alternative example for overriding the SetItemExpireCallback method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,我相信这是正确的。
如果将会话存储在数据库上,则 Sql Server 代理上有一个作业每分钟左右调用此过程:
没有会话过期的触发器。可以说这是一个触发器,它可以在哪里?没有地方可以单独放置该触发器来了解会话已过期并自动删除其自身。
另一方面,您可以做的不是创建计时器,而是当用户请求页面时,每隔 1-2 分钟触发一个函数来删除过期的页面。
因此,您可以从用户调用中触发触发器,但必须使用某种锁定使其每 1-2 分钟仅运行一次,并检查最后一次运行。
希望那有帮助。
Yes I believe that is correct.
If you store the sessions on database, then there is a Job on Sql Server Agent thats call this procedure every minute or so:
There is no trigger for session expired. Lets say that was a trigger, where that can be ? There is no place to put that trigger alone to understand that the session expired and auto-delete his self.
From the other hand what you can do, is not to create a timer, but when a user ask for a page, every 1-2 minute, trigger a function to delete the expired ones.
So you make a trigger from a user call, but you must make it run only onces every 1-2 minutes using some kind of lock, and check for the last run.
Hope thats helps.