CacheManager

Package: MachII.framework
Inherits from: framework.CommandLoaderBase
Provides an unified API for event and subroutine caching in Mach-II.

<!--- License: Copyright 2008 GreatBizTools, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Copyright: GreatBizTools, LLC Author: Kurt Wiersma (kurt@mach-ii.com) $Id: CacheManager.cfc 595 2007-12-17 02:39:01Z kurtwiersma $ Created version: 1.6.0 Updated version: 1.6.0 Notes: --->

Method Summary
public CacheManager init(AppManager appManager, [any parentCacheManager=""])

Initializes the manager.

public void addCacheHandler(CacheHandler cacheHandler, [boolean overrideCheck="false"])

Adds a cache handler.

public void clearCacheById(string id, Event event, [string criteria=""])

Clears caches by cache id (handler id) and tries to clear parent by id if not found in child.

public void clearCacheByStrategyName(string cacheName)

Clears caches by cacheName and tries to clear parent strategy by name if not found in child.

public void clearCachesByAlias(string alias, Event event, [string criteria=""])

Clears caches by alias and tries to clear parent by alias if not found in child.

public void configure()

Configures the cache handlers.

private Command createCommand(any commandNode, [string parentHandlerName=""], [string parentHandlerType=""])

Creates a command and excludes 'announce', 'event-mapping' and 'redirect' commands as they cannot be used in a cache handler.

public void disableCaching()

Disables caching.

public void enableCaching()

Enables caching.

public AppManager getAppManager()
public CacheHandler getCacheHandler(string handlerId)

Gets a cache handler by handlerId. Checks parent.

public struct getCacheHandlers()

Gets all cache handlers in a struct keyed by the handlerId.

public struct getCacheHandlersByAlias(string alias)

Gets cache handlers by alias.

public struct getCacheHandlersByEventName(string eventName)

Gets all cache handlers by event name.

public struct getCacheHandlersBySubroutine(string subroutineName)

Gets all cache handlers in subroutine name.

public any getCacheStrategyManager()

Sets the CacheStrategyManager. Returns empty string if no manager is defind.

public string getDefaultCacheName()
private string getKeyHash(string keyName)

Gets a key name hash (uppercase and hash the key name)

private Log getLog()

Gets the log.

public any getParent()

Sets the parent CacheManager instance this CacheManager belongs to. It will return empty string if no parent is defined.

public boolean isAliasDefined(string alias)

Checks if an alias is current defined and in use.

public boolean isCacheHandlerDefined(string handlerId)

Checks if a cache handler is defined. Does NOT check the parent.

public string loadCacheHandlerFromXml(string configXML, string parentHandlerName, string parentHandlerType, [boolean override="false"])

Loads a cache handler from Xml.

public void removeCacheHandler(CacheHandler cacheHandler)

Removes a cache handler. Does NOT remove from the parent.

public void setAppManager(AppManager appManager)
public void setCacheStrategyManager(CacheStrategyManager cacheStrategyManager)

Returns the CacheStrategyManager.

public string setDefaultCacheName(string defaultCacheName)
private void setLog(LogFactory logFactory)

Uses the log factory to create a log.

public void setParent(CacheManager parentCacheManager)

Returns the parent CacheManager instance this CacheManager belongs to.

Methods inherited from framework.CommandLoaderBase:   setupCache , setupPublish , setupRedirect , setupFilter , setupExecute , setupEventArg , setupAnnounce , setupViewPage , setupDefault , setupCacheClear , setupNotify , setupEventMapping , setupEventBean
Method Detail
addCacheHandler

public void addCacheHandler( CacheHandler cacheHandler, [boolean overrideCheck="false"] )

Adds a cache handler.

Parameters:
CacheHandler cacheHandler
[boolean overrideCheck="false"]

Code:

	<cffunction name="addCacheHandler" access="public" returntype="void" output="false"
		hint="Adds a cache handler.">
		<cfargument name="cacheHandler" type="MachII.framework.CacheHandler" required="true"
			hint="The cache handler you want to add." />
		<cfargument name="overrideCheck" type="boolean" required="false" default="false" />

		<cfset var handlerId = arguments.cacheHandler.getHandlerId() />
		<cfset var aliases = arguments.cacheHandler.getAliases() />
		<cfset var handlerType = arguments.cacheHandler.getParentHandlerType() />
		<cfset var currentAlias = "" />
		
		<cfif NOT arguments.overrideCheck>
			<cftry>
				<cfset StructInsert(variables.handlers, handlerId, arguments.cacheHandler, false) />
				<cfcatch type="any">
					<cfthrow type="MachII.framework.CacheHandlerAlreadyDefined"
						message="An CacheHandler with the id '#arguments.handlerId#' is already registered." />
				</cfcatch>
			</cftry>
			
			
			<cfif handlerType EQ "event">
				<cfset StructInsert(variables.handlersByEventName, handlerId, getKeyHash(arguments.cacheHandler.getParentHandlerName()), false) />
			<cfelseif handlerType EQ "subroutine">
				<cfset StructInsert(variables.handlersBySubroutineName, handlerId, getKeyHash(arguments.cacheHandler.getParentHandlerName()), false) />
			</cfif>
		<cfelse>
			<cfset variables.handlers[handlerId] = arguments.cacheHandler />
		</cfif>

		
		<cfif Len(aliases)>
			<cfloop list="#aliases#" index="currentAlias">
				<cfset variables.handlersByAliases[getKeyHash(currentAlias)][handlerId] = true />
			</cfloop>
		</cfif>
	</cffunction> 

clearCacheById

public void clearCacheById( string id, Event event, [string criteria=""] )

Clears caches by cache id (handler id) and tries to clear parent by id if not found in child.

Parameters:
string id
Event event
[string criteria=""]

Code:

	<cffunction name="clearCacheById" access="public" returntype="void" output="false"
		hint="Clears caches by cache id (handler id) and tries to clear parent by id if not found in child.">
		<cfargument name="id" type="string" required="true" />
		<cfargument name="event" type="MachII.framework.Event" required="true" />
		<cfargument name="criteria" type="string" required="false" default="" />
		
		<cfset var log = getLog() />
		
		<cfif log.isTraceEnabled()>
			<cfset log.trace("CacheManager clear cache for id '#arguments.id#', " &
					"exists: #StructKeyExists(variables.handlers, arguments.id)#, handler keys:",
					StructKeyArray(variables.handlers)) />
		</cfif>
		
		
		<cfif isCacheHandlerDefined(arguments.id)>
			<cfset getCacheHandler(arguments.id).clearCache(arguments.event, arguments.criteria) />
		<cfelseif isObject(getParent())>
			<cfset getParent().clearCacheById(arguments.id, arguments.event, arguments.criteria) />
		</cfif>
	</cffunction> 

clearCacheByStrategyName

public void clearCacheByStrategyName( string cacheName )

Clears caches by cacheName and tries to clear parent strategy by name if not found in child.

Parameters:
string cacheName

Code:

	<cffunction name="clearCacheByStrategyName" access="public" returntype="void" output="false"
		hint="Clears caches by cacheName and tries to clear parent strategy by name if not found in child.">
		<cfargument name="cacheName" type="string" required="true" />
		
		
		<cfset var cacheStrategy = getCacheStrategyManager().getCacheStrategyByName(arguments.cacheName, true) />
		
		<cfif log.isTraceEnabled()>
			<cfset log.trace("CacheManager clear cache by strategy name '#arguments.cacheName#'") />
		</cfif>
		
		<cfset cacheStrategy.flush() />
	</cffunction> 

clearCachesByAlias

public void clearCachesByAlias( string alias, Event event, [string criteria=""] )

Clears caches by alias and tries to clear parent by alias if not found in child.

Parameters:
string alias
Event event
[string criteria=""]

Code:

	<cffunction name="clearCachesByAlias" access="public" returntype="void" output="false"
		hint="Clears caches by alias and tries to clear parent by alias if not found in child.">
		<cfargument name="alias" type="string" required="true" />
		<cfargument name="event" type="MachII.framework.Event" required="true" />
		<cfargument name="criteria" type="string" required="false" default="" />
		
		<cfset var cacheHandlers = StructNew() />
		<cfset var key = "" />
		
		<cfif log.isTraceEnabled()>
			<cfset log.trace("CacheManager clear cache for alias '#arguments.alias#', " &
					"exists: #StructKeyExists(variables.handlersByAliases, getKeyHash(arguments.alias))#, " &
					"criteria: #arguments.criteria#") />
		</cfif>
		
		
		<cfif StructKeyExists(variables.handlersByAliases, getKeyHash(arguments.alias))>
			<cfset cacheHandlers = variables.handlersByAliases[getKeyHash(arguments.alias)] />
			
			<cfloop collection="#cacheHandlers#" item="key">
				<cfset getCacheHandler(key).clearCache(arguments.event, arguments.criteria) />
			</cfloop>
		<cfelseif isObject(getParent())>
			<cfset getParent().clearCachesByAlias(arguments.alias, arguments.event, arguments.criteria) />
		</cfif>
	</cffunction> 

configure

public void configure( )

Configures the cache handlers.

Parameters:

Code:

	<cffunction name="configure" access="public" returntype="void" output="false"
		hint="Configures the cache handlers.">
		
		<cfset var handlerId = "" />
		<cfset var cacheStrategy = "" />
		<cfset var strategyName = "" />
		<cfset var cacheStrategyManager = getCacheStrategyManager() />
		
		
		<cfset cacheStrategyManager.configure() />
		
		
		<cfif IsObject(getParent()) AND Len(getParent().getDefaultCacheName()) 
			AND NOT Len(getDefaultCacheName())>
			<cfset setDefaultCacheName(getParent().getDefaultCacheName()) />
		</cfif>
		
		
		<cfif StructCount(variables.handlers)>
			<cfif (NOT IsObject(getParent()) AND NOT cacheStrategyManager.containsCacheStrategies())
				OR (IsObject(getParent()) AND NOT cacheStrategyManager.containsCacheStrategies() 
					AND NOT cacheStrategyManager.getParent().containsCacheStrategies())>
				<cfthrow type="MachII.caching.NoCacheStrategiesDefined" 
					message="A &lt;cache&gt; command was encountered and there are no cache strategies defined."
					detail="Please add the 'MachII.caching.CachingProperty' to your configuration file or define strategies in the CachingProperty if you wish to use the caching features." />
			</cfif>
		</cfif>
		
		
		<cfloop collection="#variables.handlers#" item="handlerId">
			<cfset strategyName = variables.handlers[handlerId].getStrategyName() />
			
			
			<cfif NOT Len(strategyName)>
				<cfset strategyName = getDefaultCacheName() />
			</cfif>
			
			
			<cfset cacheStrategy = cacheStrategyManager.getCacheStrategyByName(strategyName, true) />
			<cfset variables.handlers[handlerId].setCacheStrategy(cacheStrategy) />
		</cfloop>
	</cffunction> 

createCommand

private Command createCommand( any commandNode, [string parentHandlerName=""], [string parentHandlerType=""] )

Creates a command and excludes 'announce', 'event-mapping' and 'redirect' commands as they cannot be used in a cache handler.

Parameters:
any commandNode
[string parentHandlerName=""]
[string parentHandlerType=""]

Code:

	<cffunction name="createCommand" access="private" returntype="MachII.framework.Command" output="false"
		hint="Creates a command and excludes 'announce', 'event-mapping' and 'redirect' commands as they cannot be used in a cache handler.">
		<cfargument name="commandNode" type="any" required="true" />
		<cfargument name="parentHandlerName" type="string" required="false" default="" />
		<cfargument name="parentHandlerType" type="string" required="false" default="" />
		
		
		<cfif ListFindNoCase("announce,event-mapping,redirect", arguments.commandNode.xmlName)>
			<cfthrow type="MachII.framework.InvalidNestedCommand"
					message="The #arguments.commandNode.xmlName# command in #arguments.parentHandlerType# named '#arguments.parentHandlerName#' is not valid inside a cache command."
					detail="The commands announce, event-mapping and redirect are now allowed inside a cache command since they cannot be replayed." />
		</cfif>
		
		<cfreturn super.createCommand(arguments.commandNode, arguments.parentHandlerName, arguments.parentHandlerType) />
	</cffunction> 

disableCaching

public void disableCaching( )

Disables caching.

Parameters:

Code:

	<cffunction name="disableCaching" access="public" returntype="void" output="false"
		hint="Disables caching.">
		
		<cfset var key = "" />
		<cfset var strategies = getCacheStrategyManager().getCacheStrategies() />
		
		<cfloop collection="#strategies#" item="key">
			<cfset strategies[key].setCacheEnabled(false) />
		</cfloop>
	</cffunction> 

enableCaching

public void enableCaching( )

Enables caching.

Parameters:

Code:

	<cffunction name="enableCaching" access="public" returntype="void" output="false"
		hint="Enables caching.">
			
		<cfset var key = "" />
		<cfset var strategies = getCacheStrategyManager().getCacheStrategies() />
		
		<cfloop collection="#strategies#" item="key">
			<cfset strategies[key].setCacheEnabled(true) />
		</cfloop>
	</cffunction> 

getAppManager

public AppManager getAppManager( )

Parameters:

Code:

	<cffunction name="getAppManager" access="public" returntype="MachII.framework.AppManager" output="false">
		<cfreturn variables.appManager />
	</cffunction> 

getCacheHandler

public CacheHandler getCacheHandler( string handlerId )

Gets a cache handler by handlerId. Checks parent.

Parameters:
string handlerId

Code:

	<cffunction name="getCacheHandler" access="public" returntype="MachII.framework.CacheHandler" output="false"
		hint="Gets a cache handler by handlerId. Checks parent.">
		<cfargument name="handlerId" type="string" required="true"
			hint="Handler id of the cache handler you want to get." />

		<cfif isCacheHandlerDefined(arguments.handlerId)>
			<cfreturn variables.handlers[arguments.handlerId] />
		<cfelseif IsObject(getParent()) AND getParent().isCacheHandlerDefined(arguments.handlerId)>
			<cfreturn getParent().getCacheHandler(arguments.handlerId) />
		<cfelse>
			<cfthrow type="MachII.framework.CacheHandlerNotDefined" 
				message="CacheHandler for cache '#arguments.handlerId#' is not defined." />
		</cfif>
	</cffunction> 

getCacheHandlers

public struct getCacheHandlers( )

Gets all cache handlers in a struct keyed by the handlerId.

Parameters:

Code:

	<cffunction name="getCacheHandlers" access="public" returntype="struct" output="false"
		hint="Gets all cache handlers in a struct keyed by the handlerId.">
		<cfreturn variables.handlers />
	</cffunction> 

getCacheHandlersByAlias

public struct getCacheHandlersByAlias( string alias )

Gets cache handlers by alias.

Parameters:
string alias

Code:

	<cffunction name="getCacheHandlersByAlias" access="public" returntype="struct" output="false"
		hint="Gets cache handlers by alias.">
		<cfargument name="alias" type="string" required="true" />
		
		<cfset var cacheHandlers = StructNew() />
		<cfset var handlerIds = StructNew() />
		<cfset var key = "" />
		
		<cfif StructKeyExists(variables.handlersByAliases, getKeyHash(arguments.alias))>
			<cfset handlerIds = variables.handlersByAliases[getKeyHash(arguments.alias)] />
			
			<cfloop collection="#handlerIds#" item="key">
				<cfset cacheHandlers[key] = getCacheHandler(key) />
			</cfloop>
		<cfelseif isObject(getParent())>
			<cfset cacheHandlers = getParent().getCacheHandlersByAlias(arguments.alias) />
		</cfif>
		
		<cfreturn cacheHandlers />
	</cffunction> 

getCacheHandlersByEventName

public struct getCacheHandlersByEventName( string eventName )

Gets all cache handlers by event name.

Parameters:
string eventName

Code:

	<cffunction name="getCacheHandlersByEventName" access="public" returntype="struct" output="false"
		hint="Gets all cache handlers by event name.">
		<cfargument name="eventName" type="string" required="true" />
		
		<cfset var cacheHandlers = StructNew() />
		<cfset var handlerIds = StructNew() />
		<cfset var key = "" />
		
		<cfif StructKeyExists(variables.handlersByEventName, getKeyHash(arguments.eventName))>
			<cfset handlerIds = variables.handlersByEventName[getKeyHash(arguments.eventName)] />
			
			<cfloop collection="#handlerIds#" item="key">
				<cfset cacheHandlers[key] = getCacheHandler(key) />
			</cfloop>
		</cfif>
		
		<cfreturn cacheHandlers />
	</cffunction> 

getCacheHandlersBySubroutine

public struct getCacheHandlersBySubroutine( string subroutineName )

Gets all cache handlers in subroutine name.

Parameters:
string subroutineName

Code:

	<cffunction name="getCacheHandlersBySubroutine" access="public" returntype="struct" output="false"
		hint="Gets all cache handlers in subroutine name.">
		<cfargument name="subroutineName" type="string" required="true" />
		
		<cfset var cacheHandlers = StructNew() />
		<cfset var handlerIds = StructNew() />
		<cfset var key = "" />
		
		<cfif StructKeyExists(variables.handlersBySubroutineName, getKeyHash(arguments.subroutineName))>
			<cfset handlerIds = variables.handlersBySubroutineName[getKeyHash(arguments.subroutineName)] />
			
			<cfloop collection="#handlerIds#" item="key">
				<cfset cacheHandlers[key] = getCacheHandler(key) />
			</cfloop>
		</cfif>
		
		<cfreturn cacheHandlers />
	</cffunction> 

getCacheStrategyManager

public any getCacheStrategyManager( )

Sets the CacheStrategyManager. Returns empty string if no manager is defind.

Parameters:

Code:

	<cffunction name="getCacheStrategyManager" access="public" returntype="any" output="false"
		hint="Sets the CacheStrategyManager. Returns empty string if no manager is defind.">
		<cfreturn variables.cacheStrategyManager />
	</cffunction> 

getDefaultCacheName

public string getDefaultCacheName( )

Parameters:

Code:

	<cffunction name="getDefaultCacheName" access="public" returntype="string" output="false">
		<cfreturn variables.defaultCacheName />
	</cffunction> 

getKeyHash

private string getKeyHash( string keyName )

Gets a key name hash (uppercase and hash the key name)

Parameters:
string keyName

Code:

	<cffunction name="getKeyHash" access="private" returntype="string" output="false"
		hint="Gets a key name hash (uppercase and hash the key name)">
		<cfargument name="keyName" type="string" required="true" />
		<cfreturn Hash(UCase(arguments.keyName)) />
	</cffunction> 

getLog

private Log getLog( )

Gets the log.

Parameters:

Code:

	<cffunction name="getLog" access="private" returntype="MachII.logging.Log" output="false"
		hint="Gets the log.">
		<cfreturn variables.log />
	</cffunction> 

getParent

public any getParent( )

Sets the parent CacheManager instance this CacheManager belongs to. It will return empty string if no parent is defined.

Parameters:

Code:

	<cffunction name="getParent" access="public" returntype="any" output="false"
		hint="Sets the parent CacheManager instance this CacheManager belongs to. It will return empty string if no parent is defined.">
		<cfreturn variables.parentCacheManager />
	</cffunction> 

init

public CacheManager init( AppManager appManager, [any parentCacheManager=""] )

Initializes the manager.

Parameters:
AppManager appManager
[any parentCacheManager=""]

Code:

	<cffunction name="init" access="public" returntype="CacheManager" output="false"
		hint="Initializes the manager.">
		<cfargument name="appManager" type="MachII.framework.AppManager" required="true" />
		<cfargument name="parentCacheManager" type="any" required="false" default=""
			hint="Optional argument for a parent cache manager. If not defined, default to zero-length string." />
		
		<cfset setAppManager(arguments.appManager) />
		
		<cfset setCacheStrategyManager(CreateObject("component", "MachII.caching.CacheStrategyManager").init()) />
		
		<cfif IsObject(arguments.parentCacheManager)>
			<cfset setParent(arguments.parentCacheManager) />
			<cfset getCacheStrategyManager().setParent(getParent().getCacheStrategyManager()) />
		</cfif>
		
		
		<cfset setLog(getAppManager().getLogFactory()) />
		
		<cfset super.init() />
		
		<cfreturn this />
	</cffunction> 

isAliasDefined

public boolean isAliasDefined( string alias )

Checks if an alias is current defined and in use.

Parameters:
string alias

Code:

	<cffunction name="isAliasDefined" access="public" returntype="boolean" output="false"
		hint="Checks if an alias is current defined and in use.">
		<cfargument name="alias" type="string" required="true" />
		
		<cfif StructKeyExists(variables.aliases, arguments.alias)>
			<cfreturn true />
		<cfelse>
			<cfreturn false />
		</cfif>
	</cffunction> 

isCacheHandlerDefined

public boolean isCacheHandlerDefined( string handlerId )

Checks if a cache handler is defined. Does NOT check the parent.

Parameters:
string handlerId

Code:

	<cffunction name="isCacheHandlerDefined" access="public" returntype="boolean" output="false"
		hint="Checks if a cache handler is defined. Does NOT check the parent.">
		<cfargument name="handlerId" type="string" required="true" 
			hint="Handler id of the cache handler you want to check." />
		<cfreturn StructKeyExists(variables.handlers, arguments.handlerId) />
	</cffunction> 

loadCacheHandlerFromXml

public string loadCacheHandlerFromXml( string configXML, string parentHandlerName, string parentHandlerType, [boolean override="false"] )

Loads a cache handler from Xml.

Parameters:
string configXML
string parentHandlerName
string parentHandlerType
[boolean override="false"]

Code:

	<cffunction name="loadCacheHandlerFromXml" access="public" returntype="string" output="false"
		hint="Loads a cache handler from Xml.">
		<cfargument name="configXML" type="string" required="true" />
		<cfargument name="parentHandlerName" type="string" required="true" />
		<cfargument name="parentHandlerType" type="string" required="true" />
		<cfargument name="override" type="boolean" required="false" default="false" />
		
		<cfset var nestedCommandNodes = arguments.configXML.xmlChildren />
		<cfset var command = "" />

		<cfset var cacheStrategy = "" />
		<cfset var cacheHandler = "" />		

		<cfset var id = "" />
		<cfset var aliases = "" />
		<cfset var strategyName = "" />
		<cfset var criteria = "" />
		<cfset var i = 0 />

		<cfif StructKeyExists(arguments.configXML.xmlAttributes, "id")>
			<cfset id = arguments.configXML.xmlAttributes["id"] />
		</cfif>		
		<cfif StructKeyExists(arguments.configXML.xmlAttributes, "aliases")>
			<cfset aliases = arguments.configXML.xmlAttributes["aliases"] />
		</cfif>
		<cfif StructKeyExists(arguments.configXML.xmlAttributes, "strategyName")>
			<cfset strategyName = arguments.configXML.xmlAttributes["strategyName"] />
		</cfif>
		<cfif StructKeyExists(arguments.configXML.xmlAttributes, "criteria")>
			<cfset criteria = arguments.configXML.xmlAttributes["criteria"] />
		</cfif>
		
		
		<cfset cacheHandler = CreateObject("component", "MachII.framework.CacheHandler").init(
			id, aliases, strategyName, criteria, arguments.parentHandlerName, arguments.parentHandlerType) />
		<cfset cacheHandler.setLog(getAppManager().getLogFactory()) />
		<cfset cacheHandler.setAppManager(getAppManager()) />
		
		
		<cfloop from="1" to="#ArrayLen(nestedCommandNodes)#" index="i">
			<cfset command = createCommand(nestedCommandNodes[i], arguments.parentHandlerName, arguments.parentHandlerType) />
			<cfset cacheHandler.addCommand(command) />
		</cfloop>
		
		
		<cfset addCacheHandler(cacheHandler, arguments.override) />
		
		<cfreturn cacheHandler.getHandlerId() />
	</cffunction> 

removeCacheHandler

public void removeCacheHandler( CacheHandler cacheHandler )

Removes a cache handler. Does NOT remove from the parent.

Parameters:
CacheHandler cacheHandler

Code:

	<cffunction name="removeCacheHandler" access="public" returntype="void" output="false"
		hint="Removes a cache handler. Does NOT remove from the parent.">
		<cfargument name="cacheHandler" type="MachII.framework.CacheHandler" required="true"
			hint="The cache handler you want to remove." />

		<cfset var handlerId = arguments.cacheHandler.getHandlerId() />
		<cfset var aliases = arguments.cacheHandler.getAliases() />
		<cfset var handlerType = arguments.cacheHandler.getParentHandlerType() />
		<cfset var currentAlias = "" />

		
		<cfset StructDelete(variables.handlers, handlerId, false) />
		
		
		<cfif handlerType EQ "event">
			<cfset StructDelete(variables.handlersByEventName[handlerId], getKeyHash(arguments.cacheHandler.getParentHandlerName()), true) />
		<cfelseif handlerType EQ "subroutine">
			<cfset StructDelete(variables.handlersBySubroutineName[handlerId], getKeyHash(arguments.cacheHandler.getParentHandlerName()), true) />
		</cfif>
		
		
		<cfif Len(aliases)>
			<cfloop list="#aliases#" index="currentAlias">
				<cfset StructDelete(variables.handlersByAliases[getKeyHash(currentAlias)], handlerId, false) />
			</cfloop>
		</cfif>
	</cffunction> 

setAppManager

public void setAppManager( AppManager appManager )

Parameters:
AppManager appManager

Code:

	<cffunction name="setAppManager" access="public" returntype="void" output="false">
		<cfargument name="appManager" type="MachII.framework.AppManager" required="true" />
		<cfset variables.appManager = arguments.appManager />
	</cffunction> 

setCacheStrategyManager

public void setCacheStrategyManager( CacheStrategyManager cacheStrategyManager )

Returns the CacheStrategyManager.

Parameters:
CacheStrategyManager cacheStrategyManager

Code:

	<cffunction name="setCacheStrategyManager" access="public" returntype="void" output="false"
		hint="Returns the CacheStrategyManager.">
		<cfargument name="cacheStrategyManager" type="MachII.caching.CacheStrategyManager" required="true" />
		<cfset variables.cacheStrategyManager = arguments.cacheStrategyManager />
	</cffunction> 

setDefaultCacheName

public string setDefaultCacheName( string defaultCacheName )

Parameters:
string defaultCacheName

Code:

	<cffunction name="setDefaultCacheName" access="public" returntype="string" output="false">
		<cfargument name="defaultCacheName" type="string" required="true" />
		<cfif getCacheStrategyManager().isCacheStrategyDefined(arguments.defaultCacheName, true)>
			<cfset variables.defaultCacheName = arguments.defaultCacheName />
		<cfelse>
			<cfthrow type="MachII.framework.DefaultStrategyNameNotAvailable"
				message="The 'defaultCacheName' was set to '#arguments.defaultCacheName#'. This strategy is not available. Please set the default to a strategy that is configured."
				detail="Available strategies:#ArrayToList(getCacheStrategyManager().getCacheStrategyNames())#" />
		</cfif>
	</cffunction> 

setLog

private void setLog( LogFactory logFactory )

Uses the log factory to create a log.

Parameters:
LogFactory logFactory

Code:

	<cffunction name="setLog" access="private" returntype="void" output="false"
		hint="Uses the log factory to create a log.">
		<cfargument name="logFactory" type="MachII.logging.LogFactory" required="true" />
		<cfset variables.log = arguments.logFactory.getLog(getMetadata(this).name) />
	</cffunction> 

setParent

public void setParent( CacheManager parentCacheManager )

Returns the parent CacheManager instance this CacheManager belongs to.

Parameters:
CacheManager parentCacheManager

Code:

	<cffunction name="setParent" access="public" returntype="void" output="false"
		hint="Returns the parent CacheManager instance this CacheManager belongs to.">
		<cfargument name="parentCacheManager" type="MachII.framework.CacheManager" required="true" />
		<cfset variables.parentCacheManager = arguments.parentCacheManager />
	</cffunction>