com.googlecode.jpattern.gwt.client.cache
Class TimedCache

java.lang.Object
  extended by com.googlecode.jpattern.gwt.client.cache.TimedCache
All Implemented Interfaces:
ICache

public class TimedCache
extends Object
implements ICache

A Cache that holds objects for a fixed maximum time

Author:
Francesco Cina 26/lug/2011

Constructor Summary
TimedCache(int timeToLiveSeconds, int checkAllElementsAfterActions)
           
 
Method Summary
 int cacheSize()
          return the total number of objects hold by the cache
 Object get(String key)
          Return the object associated to the key if exists, null otherwise
<T> T
get(String key, Class<T> clazz)
          Return the object associated to the key if exists, null otherwise
 int getHits()
          return the total number of times an object has not be found in the cache
 int getMissing()
          return the total number of times an object has not be found in the cache
 int getTotalcalls()
          return the total number of request to get an object from the cache
 void put(String key, Object value)
          Put a new object in the cache
 void remove(String key)
          Remove an object from the cache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimedCache

public TimedCache(int timeToLiveSeconds,
                  int checkAllElementsAfterActions)
Parameters:
timeToLiveSeconds - the validity time of an object in the cache
checkAllElementsAfterActions - indicate to control the validity of all the elements in the cache after n executed actions
Method Detail

put

public void put(String key,
                Object value)
Description copied from interface: ICache
Put a new object in the cache

Specified by:
put in interface ICache

get

public Object get(String key)
Description copied from interface: ICache
Return the object associated to the key if exists, null otherwise

Specified by:
get in interface ICache
Returns:

get

public <T> T get(String key,
                 Class<T> clazz)
Description copied from interface: ICache
Return the object associated to the key if exists, null otherwise

Specified by:
get in interface ICache
Returns:

remove

public void remove(String key)
Description copied from interface: ICache
Remove an object from the cache

Specified by:
remove in interface ICache

cacheSize

public int cacheSize()
Description copied from interface: ICache
return the total number of objects hold by the cache

Specified by:
cacheSize in interface ICache
Returns:

getMissing

public int getMissing()
Description copied from interface: ICache
return the total number of times an object has not be found in the cache

Specified by:
getMissing in interface ICache
Returns:

getHits

public int getHits()
Description copied from interface: ICache
return the total number of times an object has not be found in the cache

Specified by:
getHits in interface ICache
Returns:

getTotalcalls

public int getTotalcalls()
Description copied from interface: ICache
return the total number of request to get an object from the cache

Specified by:
getTotalcalls in interface ICache
Returns:


Copyright © 2011. All Rights Reserved.