com.atlassian.greenhopper.service
Class GenericCache<K extends java.io.Serializable,V>

java.lang.Object
  extended by com.atlassian.greenhopper.service.GenericCache<K,V>
Type Parameters:
K - the key, ideally a unique entity ID. Must be serializable
V - the value, normally the entity. Serializability is not enforced - if ever we want disk overflow, then that'll be required.
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean

public abstract class GenericCache<K extends java.io.Serializable,V>
extends java.lang.Object
implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean

Generic implementation of an entity cache. An Ehcache instance is used internally for storage. For configuration, see ehcache.xml

Author:
ahennecke

Field Summary
protected  net.sf.ehcache.Ehcache cache
           
 
Constructor Summary
GenericCache()
           
 
Method Summary
 void afterPropertiesSet()
           
 void clear()
          remove all entries from the cache
 void destroy()
           
 V get(K key)
           
protected abstract  java.lang.String getCacheName()
           
 void put(K key, V value)
           
 void remove(K key)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

protected net.sf.ehcache.Ehcache cache
Constructor Detail

GenericCache

public GenericCache()
Method Detail

get

public V get(K key)
Returns:
the entity that matches the key, or null if none is in the cache

put

public void put(K key,
                V value)

remove

public void remove(K key)

clear

public void clear()
remove all entries from the cache


afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

destroy

public void destroy()
             throws java.lang.Exception
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
java.lang.Exception

getCacheName

protected abstract java.lang.String getCacheName()


Copyright © 2007-2012 Atlassian. All Rights Reserved.