com.opensymphony.oscache.extra
Class CacheMapAccessEventListenerImpl

java.lang.Object
  extended by com.opensymphony.oscache.extra.CacheMapAccessEventListenerImpl
All Implemented Interfaces:
CacheEventListener, CacheMapAccessEventListener, EventListener

public class CacheMapAccessEventListenerImpl
extends Object
implements CacheMapAccessEventListener

Implementation of a CacheMapAccessEventListener. It uses the events to count the cache hit and misses.

We are not using any synchronized so that this does not become a bottleneck. The consequence is that on retrieving values, the operations that are currently being done won't be counted.

Version:
$Revision: 254 $
Author:
Alain Bergevin, Chris Miller

Field Summary
private  int hitCount
          Hit counter
private  int missCount
          Miss counter
private  int staleHitCount
          Stale hit counter
 
Constructor Summary
CacheMapAccessEventListenerImpl()
          Constructor, empty for us
 
Method Summary
 void accessed(CacheMapAccessEvent event)
          This method handles an event each time the cache is accessed
 int getHitCount()
          Returns the cache's current hit count
 int getMissCount()
          Returns the cache's current miss count
 int getStaleHitCount()
          Returns the cache's current stale hit count
 void reset()
          Resets all of the totals to zero
 String toString()
          Return the counters in a string form
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hitCount

private int hitCount
Hit counter


missCount

private int missCount
Miss counter


staleHitCount

private int staleHitCount
Stale hit counter

Constructor Detail

CacheMapAccessEventListenerImpl

public CacheMapAccessEventListenerImpl()
Constructor, empty for us

Method Detail

getHitCount

public int getHitCount()
Returns the cache's current hit count

Returns:
The hit count

getMissCount

public int getMissCount()
Returns the cache's current miss count

Returns:
The miss count

getStaleHitCount

public int getStaleHitCount()
Returns the cache's current stale hit count


accessed

public void accessed(CacheMapAccessEvent event)
This method handles an event each time the cache is accessed

Specified by:
accessed in interface CacheMapAccessEventListener
Parameters:
event - The event triggered when the cache was accessed

reset

public void reset()
Resets all of the totals to zero


toString

public String toString()
Return the counters in a string form

Overrides:
toString in class Object


Copyright © 2011 OpenSymphony. All Rights Reserved.