2011-11-22 86 views

回答

0

您需要初始化一個單例對象,即只有一個memcached對象實例。在的Application.cfc您可以在onApplicationStart方法來初始化:

<cfset application.memcachedFactory = CreateObject("component","memcachedFactory").init("ip:port")> 
<cfset application.memcached = application.memcachedFactory.getmemcached()> 

如果使用application.cfm,只設置前檢查實例:

<cfif not IsDefined("application.memcached")> 
    <cfset application.memcachedFactory = createObject("component","memcachedFactory").init("ip:port")> 
    <cfset application.memcached = application.memcachedFactory.getmemcached()> 
</cfif>