public interface CoreCache
Implementation Details
CacheEntry
when a CacheEntry get(Object cacheId)
is issued, then the provider does NOT need to follow the
implementation guidelines for reference counting specified in the javadoc of this class's methods.
A CacheEntry is created by the provider using the cache ID and value passed into the
put(EntryInfo ei, Object value);
method.
Modifier and Type | Method and Description |
---|---|
void |
clear()
This method clears everything from the cache, so that it returns to the
state it was in when it was instantiated.
|
boolean |
containsCacheId(java.lang.Object cacheId)
Returns true if memory cache contains a mapping for the specified cache
ID.
|
CacheEntry |
get(java.lang.Object cacheId)
Returns the CacheEntry identified by the specified cache ID.
|
java.util.Set<java.lang.Object> |
getCacheIds()
Returns a set view of the cache IDs contained in the memory cache.
|
java.util.Set<java.lang.Object> |
getCacheIds(java.lang.Object keyword)
Returns the cache IDs that are associated with a dependency ID.
|
java.lang.String |
getCacheName()
Returns the name of the cache instance
|
com.ibm.wsspi.cache.CacheStatistics |
getCacheStatistics()
Returns various cache statistics encapsulated int the CacheStatistics
interface.
|
java.util.Set<java.lang.Object> |
getDependencyIds()
Returns the dependency IDs for all the cache entries.
|
java.util.Set<java.lang.Object> |
getTemplateIds()
Returns the Template IDs for all the cache entries.
|
void |
invalidate(java.lang.Object id,
boolean waitOnInyvalidation)
Invalidates all the cache entries dependent on the specified cache ID.
|
void |
invalidateByCacheId(java.lang.Object cacheId,
boolean waitOnInvalidation)
Invalidates the cache id.
|
void |
invalidateByDependency(java.lang.Object dependency,
boolean waitOnInvalidation)
Invalidates all the cache entries dependent on the specified dependency ID.
|
void |
invalidateByTemplate(java.lang.String template,
boolean waitOnInvalidation)
Invalidates all the cache entries dependent on the specified template ID.
|
CacheEntry |
put(EntryInfo ei,
java.lang.Object value)
Puts an entry into the CoreCache.
|
void |
refreshEntry(java.lang.Object CacheId)
Refresh the entry by updating the LRU location.
|
void |
setEventSource(com.ibm.wsspi.cache.EventSource eventSource) |
void |
start()
This method will be invoked once Dynacache is ready to use the
CoreCache . |
void |
stop()
This method will be invoked when the application server is stopped.
|
void |
touch(java.lang.Object id,
long validatorExpirationTime,
long expirationTime)
The touch method updates the expiration times and the state of an entry
in the CoreCache.
|
void clear()
boolean containsCacheId(java.lang.Object cacheId)
cacheId
- cache ID is to be tested.true
- memory cache contains the specified
cacheID.CacheEntry get(java.lang.Object cacheId)
Implementation Guidelines: On a get
the implementation of
the CacheEntry
should pin the entry in the Cache. The internal
reference count of the CacheEntry should be incremented.
CacheEntry.incrementReferenceCount();
cacheId
- The cache ID object for the entry to be found. It cannot be
null
.null
if the
cache ID is not found in the cache.java.util.Set<java.lang.Object> getCacheIds()
Set
of cache IDs or empty set if there is no cache ID.java.util.Set<java.lang.Object> getCacheIds(java.lang.Object keyword)
Dependency elements are used to group related cache items. Cache entries
having the same depenendency ID are managed as a group. Each related
cache item shares the same dependency id, so it only takes one member of
the dependency group to get invalidated, for the rest of the group to be
evicted. The dependency ID can be as simple as just a name such as
?storeId?
keyword
- dependency ID or template ID for the groupof cache IDs.Set
of cache IDs or empty set if no cache ID is
associated with it.com.ibm.wsspi.cache.CacheStatistics getCacheStatistics()
CacheStatistics
java.util.Set<java.lang.Object> getDependencyIds()
java.util.Set<java.lang.Object> getTemplateIds()
void invalidate(java.lang.Object id, boolean waitOnInyvalidation)
Implementation Guidelines: This method unpins an entry from the cache if
the internal reference count is zero. If the CacheEntry is being used by
other clients i.e. its reference count is greater than zero, this cache
entry is marked for removal.
CacheEntry oldCacheEntry = cacheMap.remove(id);
if oldCacheEntry.getReferenceCount() > 0 then oldCacheEntry.setRemoveWhenUnpinned();
if oldCacheEntry.getReferenceCount() == 0 then
if oldCacheEntry.isPooled()
oldCacheEntry.returnToPool (pooling of CacheEntry)
else
oldCacheEntry = null (NO pooling of CacheEntry, explicit release for garbage collection)
id
- The cache ID or dependency ID. It cannot be null.waitOnInvalidation
- true
indicates that this method should not
return until the invalidations have taken effect on all
caches. false
indicates that the invalidations
will be queued for later batch processing.void invalidateByCacheId(java.lang.Object cacheId, boolean waitOnInvalidation)
Implementation Guidelines: This method unpins an entry from the cache if
the internal reference count is zero. If the CacheEntry is being used by
other clients i.e. its reference count is greater than zero, this cache
entry is marked for removal.
CacheEntry oldCacheEntry = cacheMap.remove(id);
if oldCacheEntry.getReferenceCount() > 0 then oldCacheEntry.setRemoveWhenUnpinned();
if oldCacheEntry.getReferenceCount() == 0 then
if oldCacheEntry.isPooled()
oldCacheEntry.returnToPool (pooling of CacheEntry)
else
oldCacheEntry = null (NO pooling of CacheEntry, explicit release for garbage collection)
cacheId
- The cache ID. It cannot be null.waitOnInvalidation
- true
indicates that this method should not
return until the invalidations have taken effect on all
caches. false
indicates that the invalidations
will be queued for later batch processing.void invalidateByDependency(java.lang.Object dependency, boolean waitOnInvalidation)
Implementation Guidelines: This method unpins an entry from the cache if
the internal reference count is zero. If the CacheEntry is being used by
other clients i.e. its reference count is greater than zero, this cache
entry is marked for removal.
CacheEntry oldCacheEntry = cacheMap.remove(id);
if oldCacheEntry.getReferenceCount() > 0 then oldCacheEntry.setRemoveWhenUnpinned();
if oldCacheEntry.getReferenceCount() == 0 then
if oldCacheEntry.isPooled()
oldCacheEntry.returnToPool (pooling of CacheEntry)
else
oldCacheEntry = null (NO pooling of CacheEntry, explicit release for garbage collection)
dependency
- The dependency ID. It cannot be null.waitOnInvalidation
- true
indicates that this method should not
return until the invalidations have taken effect on all
caches. false
indicates that the invalidations
will be queued for later batch processing.void invalidateByTemplate(java.lang.String template, boolean waitOnInvalidation)
Implementation Guidelines: This method unpins an entry from the cache if
the internal reference count is zero. If the CacheEntry is being used by
other clients i.e. its reference count is greater than zero, this cache
entry is marked for removal.
CacheEntry oldCacheEntry = cacheMap.remove(id);
if oldCacheEntry.getReferenceCount() > 0 then oldCacheEntry.setRemoveWhenUnpinned();
if oldCacheEntry.getReferenceCount() == 0 then
if oldCacheEntry.isPooled()
oldCacheEntry.returnToPool (pooling of CacheEntry)
else
oldCacheEntry = null (NO pooling of CacheEntry, explicit release for garbage collection)
template
- The template ID. It cannot be null.waitOnInvalidation
- true
indicates that this method should not
return until the invalidations have taken effect on all
caches. false
indicates that the invalidations
will be queued for later batch processing.CacheEntry put(EntryInfo ei, java.lang.Object value)
Implementation Guidelines: Cache providers should store a {cacheId -->
CacheEntry} association in their cache.
A CacheEntry
is a container object containing the cache key,
value and metadata for a particular cached item. The CacheEntry object is
owned by the CacheProvider.
This method unpins an entry from the cache if the internal reference
count is zero. If the CacheEntry is being used by other clients i.e. its
reference count is greater than zero, this cache entry is marked for
removal.
CacheEntry oldCacheEntry = cacheMap.put(id);
EntryInfo
.
The CacheProvider should use the getters provided on the
EntryInfo
to control and set the expiration timeout and other
characteristics of the cached item in its own cache.ei
- The metadata of the cache entry including its key.value
- The object to store in the cache.null
is returned.void refreshEntry(java.lang.Object CacheId)
cacheId
- void setEventSource(com.ibm.wsspi.cache.EventSource eventSource)
void start()
CoreCache
. It is the responsibility of the CacheProvider
to initialize the internal state of this cache instance in the
CacheProvider.createCache(CacheConfig cc)
methodvoid stop()
CacheProvider
ought to cleanup any resources
related to the this cache instancevoid touch(java.lang.Object id, long validatorExpirationTime, long expirationTime)
Implementation Guidelines: A CacheEntry
has three possible
states:
CacheEntry
.id
- The cache ID for the cache value to be found. It cannot be
null.validatorExpirationTime
- The value of validator expiration timeexpirationTime
- The value of expiration timejava.lang.String getCacheName()