|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jasig.portal.concurrency.caching.ReferenceEntityCache
org.jasig.portal.concurrency.caching.ReferenceInvalidatingEntityCache
public class ReferenceInvalidatingEntityCache
Reference implementation of IEntityCache
that is meant
for a multi-server environment in which updates to cached entities may
occur on peer caches on other JVMs, invalidating the local copy of the
entity.
Cache entries are wrapped in a CacheEntry
that records
their creation time. At intervals, cleanupCache() is called by the
cache's cleanup thread. When this happens, the class retrieves
invalidation notices from its invalidation store and purges stale entries.
A fudge factor (clockTolerance) is employed to account for differences in system clocks among servers. This may cause a valid entry to be removed from the cache if it is newer than the corresponding invalidation by less than the fudge factor. However, this should not be to frequent, and assuming the factor is appropriately set, all relevant invalidations should occur.
Nested Class Summary | |
---|---|
(package private) class |
ReferenceInvalidatingEntityCache.CacheEntry
|
Nested classes/interfaces inherited from class org.jasig.portal.concurrency.caching.ReferenceEntityCache |
---|
ReferenceEntityCache.CacheSweeper |
Field Summary | |
---|---|
private static java.lang.String |
CACHE_ID_SEQUENCE
|
private int |
cacheID
|
private long |
clockTolerance
|
private static RDBMCachedEntityInvalidationStore |
invalidationStore
|
private long |
lastUpdateMillis
|
Fields inherited from class org.jasig.portal.concurrency.caching.ReferenceEntityCache |
---|
cache, cleanupThread, entityType, log, simpleTypeName, sweepIntervalMillis, threadID |
Constructor Summary | |
---|---|
ReferenceInvalidatingEntityCache(java.lang.Class type,
int maxSize,
int maxUnusedTime,
int sweepInterval)
ReferenceInvalidatingEntityCache constructor comment. |
|
ReferenceInvalidatingEntityCache(java.lang.Class type,
int maxSize,
int maxUnusedTime,
int sweepInterval,
int clock)
ReferenceInvalidatingEntityCache constructor comment. |
Method Summary | |
---|---|
void |
add(IBasicEntity entity)
Wrap the incoming entity and add to the cache. |
void |
cleanupCache()
Remove stale entries from the cache. |
protected void |
finalize()
May want to do something with the invalidator thread. |
IBasicEntity |
get(java.lang.String key)
Unwraps and returns the cached entity. |
int |
getCacheID()
|
private static RDBMCachedEntityInvalidationStore |
getInvalidationStore()
|
private void |
initializeCacheID()
|
void |
invalidate(IBasicEntity entity)
|
private IBasicEntity |
primGet(java.lang.String key)
Returns the WRAPPED cached entity. |
private void |
primRemove(java.lang.String key)
|
void |
remove(java.lang.String key)
|
void |
removeInvalidEntities()
Retrieves invalidations that were added to the store by other caches since the last time we checked (fudged with the clockTolerance). |
java.lang.String |
toString()
Returns a String that represents the value of this object. |
void |
update(IBasicEntity entity)
First invalidate, then cache the incoming entity. |
Methods inherited from class org.jasig.portal.concurrency.caching.ReferenceEntityCache |
---|
clearCache, debug, getCache, getEntityType, setCache, size |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static RDBMCachedEntityInvalidationStore invalidationStore
private long lastUpdateMillis
private long clockTolerance
private int cacheID
private static final java.lang.String CACHE_ID_SEQUENCE
Constructor Detail |
---|
public ReferenceInvalidatingEntityCache(java.lang.Class type, int maxSize, int maxUnusedTime, int sweepInterval, int clock) throws CachingException
CachingException
public ReferenceInvalidatingEntityCache(java.lang.Class type, int maxSize, int maxUnusedTime, int sweepInterval) throws CachingException
CachingException
Method Detail |
---|
public void add(IBasicEntity entity) throws CachingException
add
in interface IEntityCache
add
in class ReferenceEntityCache
entity
- the entity to be added to the cache.
CachingException
public void cleanupCache()
cleanupCache
in interface IEntityCache
cleanupCache
in class ReferenceEntityCache
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public IBasicEntity get(java.lang.String key)
get
in interface IEntityCache
get
in class ReferenceEntityCache
key
- - the key of the entity.
private static RDBMCachedEntityInvalidationStore getInvalidationStore() throws CachingException
CachingException
public void invalidate(IBasicEntity entity) throws CachingException
entity
- org.jasig.portal.IBasicEntity
CachingException
private IBasicEntity primGet(java.lang.String key)
key
- - the key of the entity.
private void primRemove(java.lang.String key) throws CachingException
key
- the entity to be un-cached.
CachingException
public void remove(java.lang.String key) throws CachingException
remove
in interface IEntityCache
remove
in class ReferenceEntityCache
key
- - the key of the entity to be un-cached.
CachingException
public void removeInvalidEntities()
public java.lang.String toString()
toString
in class ReferenceEntityCache
public void update(IBasicEntity entity) throws CachingException
update
in interface IEntityCache
update
in class ReferenceEntityCache
entity
- the entity to be updated in the cache.
CachingException
public int getCacheID()
private void initializeCacheID() throws CachingException
CachingException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |