Skip to content

Instantly share code, notes, and snippets.

@lmajano
Created March 17, 2015 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmajano/4ef163ef1d80b84d9411 to your computer and use it in GitHub Desktop.
Save lmajano/4ef163ef1d80b84d9411 to your computer and use it in GitHub Desktop.
clientservice
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