com.metamatrix.connector.xml.cache
Class DocumentCache

java.lang.Object
  extended by com.metamatrix.connector.xml.cache.DocumentCache
All Implemented Interfaces:
IDocumentCache

public class DocumentCache
extends java.lang.Object
implements IDocumentCache

created by JChoate on Jun 22, 2005 Provides an in memory object cache backed by a file cache. Objects entering the cache should be Serializable if the file cache is going to be used. If they are not serializable, the will not be written to disk, they will just be discarded if they are removed from the in-memory cache. The cache should be thread safe and usable by any connector (or really anything)


Nested Class Summary
 class DocumentCache.CachedObject
           
static interface DocumentCache.EventSink
           
static interface DocumentCache.EventSinkFactory
           
 
Constructor Summary
DocumentCache(int maxMemoryCacheSize, int maxFileCacheSize, java.lang.String fileCacheLocation, int maxTimeToLive, ConnectorLogger log, java.lang.String identifier)
           
DocumentCache(int maxMemoryCacheSize, int maxFileCacheSize, java.lang.String fileCacheLocation, int maxTimeToLive, ConnectorLogger log, java.lang.String identifier, boolean useCleanerThread)
           
 
Method Summary
 void addToCache(java.lang.String cacheKey, java.lang.Object obj, int size, java.lang.String id)
           
static XMLDocument cacheLookup(IDocumentCache cache, java.lang.String cacheKey, java.lang.String id)
           
 void clearCache()
           
protected  void dumpCache()
           
 java.lang.Object fetchObject(java.lang.String cacheKey, java.lang.String id)
           
protected  java.util.Enumeration getCacheContents()
           
protected  int getCacheCount()
           
protected  int getCurrentFileCacheSize()
           
protected  int getCurrentMemoryCacheSize()
           
 void release(java.lang.String cacheKey, java.lang.String id)
          Called by the CachedObjectRecord contained in the connector to remove a reference on a cache item.
 void shutdownCleaner()
           
 void shutdownCleaner(boolean waitForShutdown)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentCache

public DocumentCache(int maxMemoryCacheSize,
                     int maxFileCacheSize,
                     java.lang.String fileCacheLocation,
                     int maxTimeToLive,
                     ConnectorLogger log,
                     java.lang.String identifier,
                     boolean useCleanerThread)

DocumentCache

public DocumentCache(int maxMemoryCacheSize,
                     int maxFileCacheSize,
                     java.lang.String fileCacheLocation,
                     int maxTimeToLive,
                     ConnectorLogger log,
                     java.lang.String identifier)
Method Detail

cacheLookup

public static XMLDocument cacheLookup(IDocumentCache cache,
                                      java.lang.String cacheKey,
                                      java.lang.String id)

addToCache

public void addToCache(java.lang.String cacheKey,
                       java.lang.Object obj,
                       int size,
                       java.lang.String id)
                throws ConnectorException
Specified by:
addToCache in interface IDocumentCache
Throws:
ConnectorException

release

public void release(java.lang.String cacheKey,
                    java.lang.String id)
Description copied from interface: IDocumentCache
Called by the CachedObjectRecord contained in the connector to remove a reference on a cache item.

Specified by:
release in interface IDocumentCache

fetchObject

public java.lang.Object fetchObject(java.lang.String cacheKey,
                                    java.lang.String id)
Specified by:
fetchObject in interface IDocumentCache
id - The CacheKey of the cached object.

clearCache

public void clearCache()
Specified by:
clearCache in interface IDocumentCache

shutdownCleaner

public void shutdownCleaner(boolean waitForShutdown)
                     throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

shutdownCleaner

public void shutdownCleaner()
Specified by:
shutdownCleaner in interface IDocumentCache

getCurrentMemoryCacheSize

protected int getCurrentMemoryCacheSize()

getCurrentFileCacheSize

protected int getCurrentFileCacheSize()

getCacheCount

protected int getCacheCount()

getCacheContents

protected java.util.Enumeration getCacheContents()

dumpCache

protected void dumpCache()


Copyright © 2009. All Rights Reserved.