uPortal 2.4.1
API Documentation

org.jasig.portal.concurrency.caching
Class ReferenceInvalidatingEntityCache

java.lang.Object
  extended byorg.jasig.portal.concurrency.caching.ReferenceEntityCache
      extended byorg.jasig.portal.concurrency.caching.ReferenceInvalidatingEntityCache
All Implemented Interfaces:
IEntityCache

public class ReferenceInvalidatingEntityCache
extends ReferenceEntityCache

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.

Version:
$Revision: 1.12 $
Author:
Dan Ellentuck

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.
 IBasicEntity get(java.lang.String key)
          Unwraps and returns the cached entity.
 int getCacheID()
           
 void invalidate(IBasicEntity entity)
           
 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, getEntityType, size
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReferenceInvalidatingEntityCache

public ReferenceInvalidatingEntityCache(java.lang.Class type,
                                        int maxSize,
                                        int maxUnusedTime,
                                        int sweepInterval,
                                        int clock)
                                 throws CachingException
ReferenceInvalidatingEntityCache constructor comment.


ReferenceInvalidatingEntityCache

public ReferenceInvalidatingEntityCache(java.lang.Class type,
                                        int maxSize,
                                        int maxUnusedTime,
                                        int sweepInterval)
                                 throws CachingException
ReferenceInvalidatingEntityCache constructor comment.

Method Detail

add

public void add(IBasicEntity entity)
         throws CachingException
Wrap the incoming entity and add to the cache.

Specified by:
add in interface IEntityCache
Overrides:
add in class ReferenceEntityCache
Parameters:
entity - the entity to be added to the cache.
Throws:
CachingException

cleanupCache

public void cleanupCache()
Remove stale entries from the cache.

Specified by:
cleanupCache in interface IEntityCache
Overrides:
cleanupCache in class ReferenceEntityCache

get

public IBasicEntity get(java.lang.String key)
Unwraps and returns the cached entity.

Specified by:
get in interface IEntityCache
Overrides:
get in class ReferenceEntityCache
Parameters:
key - - the key of the entity.
Returns:
org.jasig.portal.IBasicEntity

invalidate

public void invalidate(IBasicEntity entity)
                throws CachingException
Parameters:
entity - org.jasig.portal.IBasicEntity
Throws:
CachingException

remove

public void remove(java.lang.String key)
            throws CachingException
Specified by:
remove in interface IEntityCache
Overrides:
remove in class ReferenceEntityCache
Parameters:
key - - the key of the entity to be un-cached.
Throws:
CachingException

removeInvalidEntities

public void removeInvalidEntities()
Retrieves invalidations that were added to the store by other caches since the last time we checked (fudged with the clockTolerance). If a cache entry exists for the invalidation, and the entry is older than the invalidation (again, fudged with the clockTolerance), then the entry is removed. This may drop a few perfectly valid entries from the cache that are newer than the corresponding invalidation by less than the fudge factor. However, assuming the factor is appropriately set, all relevant invalidations should occur.


toString

public java.lang.String toString()
Returns a String that represents the value of this object.

Overrides:
toString in class ReferenceEntityCache
Returns:
a string representation of the receiver

update

public void update(IBasicEntity entity)
            throws CachingException
First invalidate, then cache the incoming entity.

Specified by:
update in interface IEntityCache
Overrides:
update in class ReferenceEntityCache
Parameters:
entity - the entity to be updated in the cache.
Throws:
CachingException

getCacheID

public int getCacheID()
Returns:
int

uPortal 2.4.1
API Documentation