| Package: MachII.framework.commands |
| Inherits from: framework.Command |
| A Command for clearing caching. |
<!--- 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 $Id: CacheClearCommand.cfc 422 2007-07-06 05:34:59Z pfarrell $ Created version: 1.6.0 Updated version: 1.6.0 Notes: ---> |
| Method Summary | |
|---|---|
| public CacheClearCommand |
init([string cacheName=""], [string alias=""], [string condition=""], [string criteria=""])
Initializes the command. |
| public boolean |
execute(Event event, EventContext eventContext)
Executes a caching block. |
| private string | getAlias() |
| public string | getCacheName() |
| private string | getCondition() |
| public string | getCriteria() |
| private boolean |
isAliasDefined()
Checks if an alias is defined. |
| private boolean |
isConditionDefined()
Checks if a condition is defined. |
| private void | setAlias(string alias) |
| private void | setCacheName(string cacheName) |
| private void | setCondition(string condition) |
| private void | setCriteria(string criteria) |
| Methods inherited from framework.Command: setParameters , getParameter , setLog , setParameter , getLog |
|---|
| Method Detail |
|---|
| execute |
|---|
public boolean execute( Event event, EventContext eventContext )
Executes a caching block.
Parameters:
| Event event |
| EventContext eventContext |
Code:
<cffunction name="execute" access="public" returntype="boolean" output="false"
hint="Executes a caching block.">
<cfargument name="event" type="MachII.framework.Event" required="true" />
<cfargument name="eventContext" type="MachII.framework.EventContext" required="true" />
<cfset var continue = true />
<cfset var clearCache = false />
<cfset var cacheManager = arguments.eventContext.getAppManager().getCacheManager() />
<cfset var log = getLog() />
<cfif NOT isConditionDefined()>
<cfif isAliasDefined()>
<cfif log.isDebugEnabled()>
<cfset log.debug("Clearing cache by alias '#getAlias()#' (no condition to evaluate).") />
</cfif>
<cfelse>
<cfif log.isDebugEnabled()>
<cfset log.debug("Clearing cache by cacheName '#getCacheName()#' (no condition to evaluate).") />
</cfif>
</cfif>
<cfset clearCache = true />
<cfelseif Evaluate(getCondition())>
<cfif isAliasDefined()>
<cfif log.isDebugEnabled()>
<cfset log.debug("Clearing cache by alias '#getAlias()#' (condition '#getCondition()#' evaluated true).") />
</cfif>
<cfelse>
<cfif log.isDebugEnabled()>
<cfset log.debug("Clearing cache by cacheName '#getCacheName()#' (condition '#getCondition()#' evaluated true).") />
</cfif>
</cfif>
<cfset clearCache = true />
<cfelse>
<cfif isAliasDefined()>
<cfif log.isDebugEnabled()>
<cfset log.debug("Cannot clear cache by alias '#getAlias()#' (condition '#getCondition()#' evaluated false).") />
</cfif>
<cfelse>
<cfif log.isDebugEnabled()>
<cfset log.debug("Cannot clear cache by cacheName '#getCacheName()#' (condition '#getCondition()#' evaluated false).") />
</cfif>
</cfif>
</cfif>
<cfif clearCache>
<cfif isAliasDefined()>
<cfset cacheManager.clearCachesByAlias(getAlias(), arguments.event, getCriteria()) />
<cfelse>
<cfset cacheManager.clearCacheByName(getCacheName(), arguments.event, getCriteria()) />
</cfif>
</cfif>
<cfreturn continue />
</cffunction>
| getAlias |
|---|
private string getAlias( )
Parameters:
Code:
<cffunction name="getAlias" access="private" returntype="string" output="false"> <cfreturn variables.alias /> </cffunction>
| getCacheName |
|---|
public string getCacheName( )
Parameters:
Code:
<cffunction name="getCacheName" access="public" returntype="string" output="false"> <cfreturn variables.cacheName /> </cffunction>
| getCondition |
|---|
private string getCondition( )
Parameters:
Code:
<cffunction name="getCondition" access="private" returntype="string" output="false"> <cfreturn variables.condition /> </cffunction>
| getCriteria |
|---|
public string getCriteria( )
Parameters:
Code:
<cffunction name="getCriteria" access="public" returntype="string" output="false"> <cfreturn variables.criteria /> </cffunction>
| init |
|---|
public CacheClearCommand init( [string cacheName=""], [string alias=""], [string condition=""], [string criteria=""] )
Initializes the command.
Parameters:
| [string cacheName=""] |
| [string alias=""] |
| [string condition=""] |
| [string criteria=""] |
Code:
<cffunction name="init" access="public" returntype="CacheClearCommand" output="false" hint="Initializes the command."> <cfargument name="cacheName" type="string" required="false" default="" /> <cfargument name="alias" type="string" required="false" default="" /> <cfargument name="condition" type="string" required="false" default="" /> <cfargument name="criteria" type="string" required="false" default="" /> <cfset setAlias(arguments.alias) /> <cfset setCondition(arguments.condition) /> <cfset setCacheName(arguments.cacheName) /> <cfset setCriteria(arguments.criteria) /> <cfreturn this /> </cffunction>
| isAliasDefined |
|---|
private boolean isAliasDefined( )
Checks if an alias is defined.
Parameters:
Code:
<cffunction name="isAliasDefined" access="private" returntype="boolean" output="false" hint="Checks if an alias is defined."> <cfreturn Len(variables.alias) /> </cffunction>
| isConditionDefined |
|---|
private boolean isConditionDefined( )
Checks if a condition is defined.
Parameters:
Code:
<cffunction name="isConditionDefined" access="private" returntype="boolean" output="false" hint="Checks if a condition is defined."> <cfreturn Len(variables.condition) /> </cffunction>
| setAlias |
|---|
private void setAlias( string alias )
Parameters:
| string alias |
Code:
<cffunction name="setAlias" access="private" returntype="void" output="false"> <cfargument name="alias" type="string" required="true" /> <cfset variables.alias = arguments.alias /> </cffunction>
| setCacheName |
|---|
private void setCacheName( string cacheName )
Parameters:
| string cacheName |
Code:
<cffunction name="setCacheName" access="private" returntype="void" output="false"> <cfargument name="cacheName" type="string" required="true" /> <cfset variables.cacheName = arguments.cacheName /> </cffunction>
| setCondition |
|---|
private void setCondition( string condition )
Parameters:
| string condition |
Code:
<cffunction name="setCondition" access="private" returntype="void" output="false"> <cfargument name="condition" type="string" required="true" /> <cfset variables.condition = arguments.condition /> </cffunction>
| setCriteria |
|---|
private void setCriteria( string criteria )
Parameters:
| string criteria |
Code:
<cffunction name="setCriteria" access="private" returntype="void" output="false"> <cfargument name="criteria" type="string" required="true" /> <cfset variables.criteria = arguments.criteria /> </cffunction>