public class FIFOEJBObjectCache extends LruEJBCache implements EJBObjectCache
| Modifier and Type | Class and Description |
|---|---|
protected static class |
FIFOEJBObjectCache.EJBObjectCacheItem |
LruCache.LruCacheItemBaseCache.CacheItem| Modifier and Type | Field and Description |
|---|---|
protected static boolean |
_printRefCount |
protected EJBObjectCacheListener |
listener |
protected int |
maxCacheSize |
protected String |
name |
protected Object |
refCountLock |
protected int |
totalRefCount |
cacheNamedefaultMaxEntries, head, isUnbounded, listSize, NO_TIMEOUT, tail, timeout, trimCountbucketLocks, buckets, entryCount, hitCount, listeners, maxBuckets, maxEntries, missCount, refreshFlags, removalCount, threshold| Constructor and Description |
|---|
FIFOEJBObjectCache(String name)
default constructor
|
FIFOEJBObjectCache(String name,
long timeout)
constructor with specified timeout
|
| Modifier and Type | Method and Description |
|---|---|
protected BaseCache.CacheItem |
createItem(int hashCode,
Object key,
Object value,
int size)
create new item
|
protected void |
decrementReferenceCount() |
protected void |
decrementReferenceCount(int count) |
Object |
get(Object key)
get the item stored at the key.
|
Object |
get(Object key,
boolean incrementRefCount) |
Map |
getStats()
get the stats snapshot
|
protected void |
incrementReferenceCount() |
void |
init(int maxEntries,
int numberOfVictimsToSelect,
long timeout,
float loadFactor,
Properties props) |
protected Object |
internalGet(int hashCode,
Object key,
boolean incrementRefCount) |
protected Object |
internalPut(int hashCode,
Object key,
Object value,
int size,
boolean incrementRefCount) |
protected Object |
internalRemove(Object key,
boolean decrementRefCount) |
protected boolean |
isThresholdReached()
has cache reached its threshold
|
protected void |
itemAccessed(BaseCache.CacheItem item)
this item is accessed
|
protected void |
itemRemoved(BaseCache.CacheItem item)
item value has been removed from the cache
|
static void |
main(String[] args) |
void |
print() |
Object |
put(Object key,
Object value)
/**
cache the given value at the specified key and return previous value
|
Object |
put(Object key,
Object value,
boolean incrementRefCount) |
Object |
remove(Object key)
remove the item stored at the key.
|
Object |
remove(Object key,
boolean decrementRefCount) |
void |
setEJBObjectCacheListener(EJBObjectCacheListener listener) |
void |
trimExpiredEntries(int maxCount)
trim the expired entries from the cache.
|
itemAdded, setCacheName, trimLrugetStatByName, init, itemRefreshed, setTimeout_put, _remove, _removeItem, add, add, addCacheListener, clear, clearStats, contains, decrementEntryCount, destroy, elements, eq, get, getAll, getEntryCount, getIndex, getIndex, handleOverflow, hash, incrementAddCount, incrementEntryCount, incrementHitCount, incrementMissCount, incrementOverflowCount, incrementRefreshCount, incrementRemovalCount, init, init, isEmpty, keys, loadValue, notifyRefresh, put, remove, remove, removeAll, trimItem, values, waitRefreshclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitadd, add, addCacheListener, clear, clearStats, contains, destroy, elements, getAll, getEntryCount, getIndex, getStatByName, init, init, isEmpty, keys, notifyRefresh, put, remove, removeAll, values, waitRefreshprotected int maxCacheSize
protected String name
protected EJBObjectCacheListener listener
protected Object refCountLock
protected int totalRefCount
protected static final boolean _printRefCount
public FIFOEJBObjectCache(String name)
public FIFOEJBObjectCache(String name, long timeout)
public void init(int maxEntries,
int numberOfVictimsToSelect,
long timeout,
float loadFactor,
Properties props)
init in interface EJBObjectCachepublic void setEJBObjectCacheListener(EJBObjectCacheListener listener)
setEJBObjectCacheListener in interface EJBObjectCachepublic Object get(Object key)
BaseCachepublic Object get(Object key, boolean incrementRefCount)
get in interface EJBObjectCachepublic Object put(Object key, Object value)
BaseCachepublic Object put(Object key, Object value, boolean incrementRefCount)
put in interface EJBObjectCachepublic Object remove(Object key)
BaseCachepublic Object remove(Object key, boolean decrementRefCount)
remove in interface EJBObjectCacheprotected boolean isThresholdReached()
BaseCacheisThresholdReached in class BaseCacheprotected void itemAccessed(BaseCache.CacheItem item)
LruCacheitemAccessed in class LruCacheitem - CacheItem accessed
Cache bucket is already synchronized by the callerprotected void itemRemoved(BaseCache.CacheItem item)
LruCacheitemRemoved in class LruCacheitem - CacheItem that was just removed
Cache bucket is already synchronized by the callerprotected Object internalPut(int hashCode, Object key, Object value, int size, boolean incrementRefCount)
public void print()
protected BaseCache.CacheItem createItem(int hashCode, Object key, Object value, int size)
LruCachecreateItem in class LruCachehashCode - for the entrykey - Object keyvalue - Object valuesize - size in bytes of the item
subclasses may override to provide their own CacheItem extensions
e.g. one that permits persistence.public void trimExpiredEntries(int maxCount)
LruCachetrimExpiredEntries in interface CachetrimExpiredEntries in class LruCachemaxCount - maximum number of invalid entries to trim
specify Integer.MAX_VALUE to trim all invalid entries
This call is to be scheduled by a thread managed by the container.
NOTE: this algorithm assumes that all the entries in the cache have
identical timeout (otherwise traversing from tail won't be right).protected void incrementReferenceCount()
protected void decrementReferenceCount()
protected void decrementReferenceCount(int count)
Copyright © 2017. All rights reserved.