Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CFLOCK

Engaged ,
Apr 04, 2013 Apr 04, 2013

I just wanted to know when I need use CFLOCK.

For example, do I need to CFLOCK when I assign my data source database in my Application.cfc.

If I use CFLOCK then web server will lock the database for timeout seconds to connect the database server?

Your information and help is great appreciated,

Regards,

Iccsi,

615
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Apr 04, 2013 Apr 04, 2013

You need to lock when there will be a race condition, that's about it. http://en.wikipedia.org/wiki/Race_condition#Example

onApplicationStart() is single threaded when it's called as part of the application lifecycle (http://adamcameroncoldfusion.blogspot.co.nz/2012/07/onapplicationstart-is-not-intrinsically.html), so there's no need to worry about locking application-scoped stuff in there.

--

Adam

Translate
LEGEND ,
Apr 04, 2013 Apr 04, 2013

You need to lock when there will be a race condition, that's about it. http://en.wikipedia.org/wiki/Race_condition#Example

onApplicationStart() is single threaded when it's called as part of the application lifecycle (http://adamcameroncoldfusion.blogspot.co.nz/2012/07/onapplicationstart-is-not-intrinsically.html), so there's no need to worry about locking application-scoped stuff in there.

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 04, 2013 Apr 04, 2013

Thanks a million for the information and help.

I see onApplicationStart even in the file.

Must I put this event within cfcomponent?

Should this event only can have once and in Application.cfc, since it trigger on application start.

Thanks again for a million for helping and information,

Regards,

Iccsi,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 04, 2013 Apr 04, 2013

onApplicationStart() must be in a CFC, yes - specifically Application.cfc as you say. One can only have one method of a given name in a CFC, and Application.cfc is no different in this regard, so only one onApplicationStart() method, yes. I think that's what you're asking.

However one can use inheritance with Application.cfcs just like with any other CFC, so one can have this:

/mainapp/Application.cfc

/mainapp/subsection/Application.cfc - extends /mainapp/Application.cfc.

This means one can implement your general-case event handlers in /mainapp/Application.cfc, and if the subsection requires different behaviour, then the Application.cfc there can override the event handlers as required. Plus they can call the extended Application.cfc's event handlers too, via - for example - super.onApplicationStart().

It's all well documented:

Application.cfc reference:

http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-74fa.html

Defining the application and its event handlers in Application.cfc

http://help.adobe.com/en_US/ColdFusion/10.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7d39.htm...

And also google for "application.cfc". Plenty of people have blogged about it.

HTH.

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 04, 2013 Apr 04, 2013
LATEST

Thanks a million for helping and information,

Regards,

Iccsi,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources