CacheStats

Package: MachII.caching
Holds cache stats for a concrete strategy.

<!--- 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: CacheStats.cfc 701 2008-03-22 22:07:01Z peterfarrell $ Created version: 1.6.0 Updated version: 1.6.0 Notes: Stats on a particular cache's performance may be tracked by a Mach-II provided CFC that exposes several metrics. One potential use of these metrics is to display them inside a dashboard that can be monitored while the application is running. The metrics tracked by Mach-II are as follows: * Cache hits * Cache misses * Cache active element count * Cache total element count * Cache evictions - number of elements that the cache removed to make room for new elements --->

Method Summary
public CacheStats init()

Initializes the stats.

public void decrementActiveElements([numeric amount="1"])
public void decrementTotalElements([numeric amount="1"])
public numeric getActiveElements()
public numeric getCacheHits()
public numeric getcacheMisses()
public numeric getEvictions()
public struct getExtraStats()
public numeric getTotalElements()
public void incrementActiveElements([numeric amount="1"])
public void incrementCacheHits([numeric amount="1"])

Increments the number of hits by the default of 1 or by the amount passed.

public void incrementCacheMisses([numeric amount="1"])
public void incrementEvictions([numeric amount="1"])
public void incrementTotalElements([numeric amount="1"])
public numeric setActiveElements(numeric activeElements)
public void setExtraStat(string statName, any statValue)

Sets an extra stats value by stat name.

public numeric setTotalElements(numeric totalElements)
Method Detail
decrementActiveElements

public void decrementActiveElements( [numeric amount="1"] )

Parameters:
[numeric amount="1"]

Code:

	<cffunction name="decrementActiveElements" access="public" returntype="void" output="false">
		<cfargument name="amount" type="numeric" required="false" default="1" />
		<cfset variables.activeElements = variables.activeElements - arguments.amount />
	</cffunction> 

decrementTotalElements

public void decrementTotalElements( [numeric amount="1"] )

Parameters:
[numeric amount="1"]

Code:

	<cffunction name="decrementTotalElements" access="public" returntype="void" output="false">
		<cfargument name="amount" type="numeric" required="false" default="1" />
		<cfset variables.totalElements = variables.totalElements - arguments.amount />
	</cffunction> 

getActiveElements

public numeric getActiveElements( )

Parameters:

Code:

	<cffunction name="getActiveElements" access="public" returntype="numeric" output="false">
		<cfreturn variables.activeElements />
	</cffunction> 

getCacheHits

public numeric getCacheHits( )

Parameters:

Code:

	<cffunction name="getCacheHits" access="public" returntype="numeric" output="false">
		<cfreturn variables.cacheHits />
	</cffunction> 

getcacheMisses

public numeric getcacheMisses( )

Parameters:

Code:

	<cffunction name="getcacheMisses" access="public" returntype="numeric" output="false">
		<cfreturn variables.cacheMisses />
	</cffunction> 

getEvictions

public numeric getEvictions( )

Parameters:

Code:

	<cffunction name="getEvictions" access="public" returntype="numeric" output="false">
		<cfreturn variables.evictions />
	</cffunction> 

getExtraStats

public struct getExtraStats( )

Parameters:

Code:

	<cffunction name="getExtraStats" access="public" returntype="struct" output="false">
		<cfreturn variables.extraStats />
	</cffunction> 

getTotalElements

public numeric getTotalElements( )

Parameters:

Code:

	<cffunction name="getTotalElements" access="public" returntype="numeric" output="false">
		<cfreturn variables.totalElements />
	</cffunction> 

incrementActiveElements

public void incrementActiveElements( [numeric amount="1"] )

Parameters:
[numeric amount="1"]

Code:

	<cffunction name="incrementActiveElements" access="public" returntype="void" output="false">
		<cfargument name="amount" type="numeric" required="false" default="1" />
		<cfset variables.activeElements = variables.activeElements + arguments.amount />
	</cffunction> 

incrementCacheHits

public void incrementCacheHits( [numeric amount="1"] )

Increments the number of hits by the default of 1 or by the amount passed.

Parameters:
[numeric amount="1"]

Code:

	<cffunction name="incrementCacheHits" access="public" returntype="void" output="false"
		hint="Increments the number of hits by the default of 1 or by the amount passed.">
		<cfargument name="amount" type="numeric" required="false" default="1" />
		<cfset variables.cacheHits = variables.cacheHits + arguments.amount />
	</cffunction> 

incrementCacheMisses

public void incrementCacheMisses( [numeric amount="1"] )

Parameters:
[numeric amount="1"]

Code:

	<cffunction name="incrementCacheMisses" access="public" returntype="void" output="false">
		<cfargument name="amount" type="numeric" required="false" default="1" />
		<cfset variables.cacheMisses = variables.cacheMisses + arguments.amount />
	</cffunction> 

incrementEvictions

public void incrementEvictions( [numeric amount="1"] )

Parameters:
[numeric amount="1"]

Code:

	<cffunction name="incrementEvictions" access="public" returntype="void" output="false">
		<cfargument name="amount" type="numeric" required="false" default="1" />
		<cfset variables.evictions = variables.evictions + arguments.amount />
	</cffunction> 

incrementTotalElements

public void incrementTotalElements( [numeric amount="1"] )

Parameters:
[numeric amount="1"]

Code:

	<cffunction name="incrementTotalElements" access="public" returntype="void" output="false">
		<cfargument name="amount" type="numeric" required="false" default="1" />
		<cfset variables.totalElements = variables.totalElements + arguments.amount />
	</cffunction> 

init

public CacheStats init( )

Initializes the stats.

Parameters:

Code:

	<cffunction name="init" access="public" returntype="CacheStats" output="false"
		hint="Initializes the stats.">
		<cfreturn this />
	</cffunction> 

setActiveElements

public numeric setActiveElements( numeric activeElements )

Parameters:
numeric activeElements

Code:

	<cffunction name="setActiveElements" access="public" returntype="numeric" output="false">
		<cfargument name="activeElements" type="numeric" required="true" />
		<cfset variables.activeElements = arguments.activeElements />
	</cffunction> 

setExtraStat

public void setExtraStat( string statName, any statValue )

Sets an extra stats value by stat name.

Parameters:
string statName
any statValue

Code:

	<cffunction name="setExtraStat" access="public" returntype="void" output="false"
		hint="Sets an extra stats value by stat name.">
		<cfargument name="statName" type="string" required="true" />
		<cfargument name="statValue" type="any" required="true" />
		<cfset variables.extraStats[statName] = statValue />
	</cffunction> 

setTotalElements

public numeric setTotalElements( numeric totalElements )

Parameters:
numeric totalElements

Code:

	<cffunction name="setTotalElements" access="public" returntype="numeric" output="false">
		<cfargument name="totalElements" type="numeric" required="true" />
		<cfset variables.totalElements = arguments.totalElements />
	</cffunction>