Use underlying JAVA function to create UUID instead of createUUID()!

Coldfusion createUUID() function is slow. I find using the underlying JAVA class UUID in the java.util package is much faster. Here’s how we do it in coldfusion -

<cfset myUUID = createobject(“java”, “java.util.UUID”) .randomUUID().toString()/>

The createObject function allows us to access the underlying JAVA functions, so we access the java.util.UUID class and then create the UUID using the randomUUID() function and finally converting to string using toString() function. If you will be creating UUID more than once on the page i would recommend creating the object once at the top if the page and then using the functions to create the UUID.

Just another example of the using the awesome power of JAVA in coldfusion.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.