是否应该始终将cflock与SESSION范围变量一起使用? [英] Should I always need to use cflock with SESSION scope variables?
问题描述
我有一个简单的Form,它在提交时会在SESSION中设置一个变量,例如
I have a simple Form , which on submission sets a variable in SESSION like
<cfset SESSION.shownote = 1>
向用户发送确认电子邮件后,我只是从会话中删除此变量.
After firing an confirmation Email to the user , I am just deleting this variable from the Session.
<cfset structdelete(SESSION,"shownote")>
在这种情况下,我真的需要使用cflock吗?我想不到这里的比赛条件.
Do I really need to user cflock in this case ? I can not think of a Race condition here.
随着会话的变化,一个用户到另一个用户的差异,有人可以建议我在哪种情况下使用带有会话变量的cflock吗?
As SESSION varies from one user to another , Can anyone please suggest me exactly on which situation we should use cflock with session variables?
我还听说CF9和CF10自动处理会话锁定,是真的吗?
I have also heard that, CF9 and CF10 automatically handles session locking , is it true?
推荐答案
我认为,如果您在此处回答自己的问题,可能需要进行一些谷歌搜索.
A bit of googling probably could have had you answer your own question here, I think.
但是,无论如何,我很久以前就在我的博客上写下了它:"问题:何时锁定范围".
But, anyway, I wrote this up on my blog a while back: "Question: when to lock scopes".
最重要的是,没有内在的需要锁定会话范围(自CFMX 6.0起),但是-与任何代码一样-应该确保不要在自己的代码中创建竞争条件,并且明智地使用锁定可以减轻这种情况.
The bottom line is that there's no intrinsic need to lock the session scope (since CFMX 6.0), however - as with any code - one should ensure not to create race conditions in one's code, and sensible use of locking mitigates this.
这篇关于是否应该始终将cflock与SESSION范围变量一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!