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

CFINVOKE - Need unique value every time, danger of duplicates?

New Here ,
Nov 05, 2011 Nov 05, 2011

Using CFINVOKE to generate unique UUID to insert into DB. If multiple users hit the app, is there any danger that one UUID could be returned to multiple users?

It's a user registration page. On form post, validation page invokes a CFC to generate a UUID. Not using any <CFSET> in the CFC, also aware of making sure to VAR any variables in a CFC.

If two users register at the same time, the CFC called at the same time by each, is there ANY chance both users could get the same result? This is not desired.

I guess my question is in regards to scope. How can I scope a CFC so that it's specific to the page that is calling it?

581
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 ,
Nov 06, 2011 Nov 06, 2011
Using CFINVOKE to generate unique UUID to insert into DB. If multiple users hit the app, is there any danger that one UUID could be returned to multiple users?

No.  None.  You can actually find these things out for yourself.  Googling "java UUID" yields these three links within the first three results (the second is a link from the first):

http://download.oracle.com/javase/6/docs/api/java/util/UUID.html

http://www.ietf.org/rfc/rfc4122.txt

http://en.wikipedia.org/wiki/Universally_unique_identifier

I guess my question is in regards to scope. How can I scope a CFC so that it's specific to the page that is calling it?

That's a different question.  However if you're just making a transient call to the CFC (ie: you're specifying the CFC name in the COMPONENT attribute, rather than passing it an existing instance of the CFC you've created earlier), then the object created under the hood will be specific to the request making it.  Even if you are passing it an object, unless you've made a point of creating it in a shared scope, it'll be specific to the request.  And this would have no impact on the uniqueness of a UUID anyhow.

--

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
New Here ,
Nov 06, 2011 Nov 06, 2011
LATEST

Thanks! Uniqueness of UUID is not issue. It is the scope issue you mentioned. Want to make sure each call to the CFC is unique - do not want multiple calls to share any shared/cached CFC results. Here is an example of how I use the CFINVOKE in the CFC:

<cfinvoke component="cfc.createGuid" method="createGuid" returnvariable="guid"></cfinvoke>

How can I make sure it's not in a shared/cached scope?

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