Class LRUCacheImpl
- java.lang.Object
-
- com.sun.gjc.spi.base.datastructure.LRUCacheImpl
-
- All Implemented Interfaces:
Cache
- Direct Known Subclasses:
FIXEDCacheImpl
public class LRUCacheImpl extends Object implements Cache
- Author:
- Shalini M
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LRUCacheImpl.CacheEntry
Cache object that has an entry.
-
Constructor Summary
Constructors Constructor Description LRUCacheImpl(PoolInfo poolInfo, int maxSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToCache(CacheObjectKey key, Object o, boolean force)
Add the key and entry value into the cache.Object
checkAndUpdateCache(CacheObjectKey key)
Check if an entry is found for this key object.void
clearCache()
Clears the statement cachevoid
flushCache()
Closing all statements in statement cache and flush the statement cache of all the statements.int
getMaxSize()
int
getSize()
Returns the number of entries in the statement cacheboolean
isSynchronized()
Check if the statement cache is synchronized.void
purge()
Remove all statements stored in the statement cache after closing the statement objects.void
purge(Object obj)
Remove the specified entry stored in the statement cache after closing the statement object associated with this entry.
-
-
-
Field Detail
-
_logger
protected static final Logger _logger
-
-
Constructor Detail
-
LRUCacheImpl
public LRUCacheImpl(PoolInfo poolInfo, int maxSize)
-
-
Method Detail
-
checkAndUpdateCache
public Object checkAndUpdateCache(CacheObjectKey key)
Check if an entry is found for this key object. If found, the entry is put in the result object and back into the list.- Specified by:
checkAndUpdateCache
in interfaceCache
- Parameters:
key
- key whose mapping entry is to be checked.- Returns:
- result object that contains the key with the entry if not null when (1) object not found in cache
-
addToCache
public void addToCache(CacheObjectKey key, Object o, boolean force)
Add the key and entry value into the cache.- Specified by:
addToCache
in interfaceCache
- Parameters:
key
- key that contains the sql string and its type (PS/CS)o
- entry that is the wrapper of PreparedStatement or CallableStatementforce
- If the already existing key is to be overwritten
-
clearCache
public void clearCache()
Clears the statement cache- Specified by:
clearCache
in interfaceCache
-
flushCache
public void flushCache()
Description copied from interface:Cache
Closing all statements in statement cache and flush the statement cache of all the statements. Used when a physical connection to the underlying resource manager is destroyed.- Specified by:
flushCache
in interfaceCache
-
purge
public void purge()
Description copied from interface:Cache
Remove all statements stored in the statement cache after closing the statement objects. Used when the statement cache size exceeds user defined maximum cache size.
-
purge
public void purge(Object obj)
Description copied from interface:Cache
Remove the specified entry stored in the statement cache after closing the statement object associated with this entry. Used when statement is being reclaimed and is being used for the subsequent requests from the application.
-
getSize
public int getSize()
Returns the number of entries in the statement cache
-
getMaxSize
public int getMaxSize()
-
isSynchronized
public boolean isSynchronized()
Description copied from interface:Cache
Check if the statement cache is synchronized.- Specified by:
isSynchronized
in interfaceCache
- Returns:
- boolean synchronized flag.
-
-