Created
March 17, 2015 21:47
-
-
Save lmajano/4ef163ef1d80b84d9411 to your computer and use it in GitHub Desktop.
clientservice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component singleton accessors="true"{ | |
property name="clientCache"; | |
function init(){ | |
clientCache = {}; | |
return this; | |
} | |
function getCurrentClient(){ | |
var clientDomain = listFirst( cgi.http_host, "." ); | |
if( !structKeyExists( variables.clientCache, clientDomain ) ){ | |
lock name="client.#clientDomain#" type="exclusive" throwOnTimeout="true"{ | |
if( !structKeyExists( variables.clientCache, clientDomain ) ){ | |
variables.clientCache[ clientDomain ] = getClient( clientDomain ); | |
} | |
} | |
} | |
return variables.clientCache[ clientDomain ]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment