org.biojava.bio.structure.domain
Class SerializableCache<K,V>

java.lang.Object
  extended by org.biojava.bio.structure.domain.SerializableCache<K,V>
Type Parameters:
K - The key type of the cache
V - the value type to be stored on the cache
Direct Known Subclasses:
CachedRemoteScopInstallation, RemoteDomainProvider, RemotePDPProvider

public class SerializableCache<K,V>
extends Object

A class that provides all that is necessary to create a Serializable Cache

Since:
3.0.3
Author:
Andreas Prlic

Field Summary
protected  String cacheFileName
           
protected  Map<K,V> serializedCache
           
 
Constructor Summary
SerializableCache(String cacheFileName)
          set cacheFileName to null to disable caching
 
Method Summary
 void cache(K name, V data)
          This will not cache null values.
 void disableCache()
           
 void enableCache()
           
 void flushCache()
           
 V get(K name)
           
 boolean isCacheEnabled()
           
 boolean isDebug()
           
 Map<K,V> reloadFromFile()
           
 void setDebug(boolean debug)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cacheFileName

protected String cacheFileName

serializedCache

protected Map<K,V> serializedCache
Constructor Detail

SerializableCache

public SerializableCache(String cacheFileName)
set cacheFileName to null to disable caching

Parameters:
cacheFileName -
Method Detail

isCacheEnabled

public boolean isCacheEnabled()

cache

public void cache(K name,
                  V data)
This will not cache null values. Null means not cached yet. If you want to cache "no data exists" use e.g. empty collections to represent this.

Parameters:
name -
data -

get

public V get(K name)

disableCache

public void disableCache()

enableCache

public void enableCache()

reloadFromFile

public Map<K,V> reloadFromFile()

flushCache

public void flushCache()

isDebug

public boolean isDebug()

setDebug

public void setDebug(boolean debug)