public class DependentCache extends Object implements Serializable
IOObject
s that some cache element depends upon.
Dependency objects can be added to the dependency list by calling addObject
;
The lifecycle of a DependentCache
is typically:
DependentCache
is created [UNINITIALIZED]
DependentCacheManager
feeds any IOHashKeys
to the DependentCache
;
If this cache depends on any of the IOHashKeys
, the cached is marked as "Ready to expire"
Modifier and Type | Class and Description |
---|---|
static class |
DependentCache.Status
Encapsulates the different states that the
DependentCache may have. |
Modifier and Type | Field and Description |
---|---|
static DependentCache.Status |
EXPIRED
The cache has been expired, and is probably being repopulated as we speak.
|
static DependentCache.Status |
READY
The cache is initialized, and has received content, and is able to return the content.
|
static DependentCache.Status |
READY_TO_EXPIRE
The cache has been flagged to expire the content at the first possible moment.
|
static DependentCache.Status |
UNINITIALIZED
The cache isn't initialized, and has not received any content yet.
|
Modifier | Constructor and Description |
---|---|
protected |
DependentCache()
Constructs a new
DependentCache instance, with a status of UNINITIALIZED |
Modifier and Type | Method and Description |
---|---|
void |
addObject(IOHashKey key)
Makes the contents of this cache depend on the specified object.
|
void |
addObject(IOObject object)
Makes the contents of this cache depend on the object.
|
protected void |
clearDependencyList()
Clears the list of dependencies.
|
void |
expire()
Sets the status of this content to READY_TO_EXPIRE.
|
Object |
getContent()
Retrieves the content of this cache.
|
Object |
getOldContent()
Retrieves the content returned by
getContent() , but don't expire the content even if it is marked as
ready to expire. |
DependentCache.Status |
getStatus()
Retrieves the status of this content.
|
boolean |
includesKeys(IOHashKey[] keys)
Checks whether or not the content of this cache depends on one or more of the given
IOObjects . |
void |
setContent(Object content)
Sets the content to the specified object.
|
void |
setExpireTime(long newExpireTime) |
String |
toString()
Retreives a string representation of this dependent cache.
|
void |
unableToRepopulate() |
public static final DependentCache.Status UNINITIALIZED
public static final DependentCache.Status READY
public static final DependentCache.Status READY_TO_EXPIRE
public static final DependentCache.Status EXPIRED
protected DependentCache()
DependentCache
instance, with a status of UNINITIALIZED
public void addObject(IOObject object)
object
- the object to make this content dependent onpublic void addObject(IOHashKey key)
key
- the object to make this content dependent onpublic boolean includesKeys(IOHashKey[] keys)
IOObjects
.keys
- the IOObjects
to check for dependenciesIOObjects
; false otherwisepublic void setExpireTime(long newExpireTime)
public void setContent(Object content)
content
- the content belonging to this cachepublic Object getContent()
CacheDependency
removed.
If this method returns null, it is up to the caller to re-populate the contents of this cache.
This method should normally be called, and when the caller receives a null, it is the
caller's responsibility to repopulate the cache.public void unableToRepopulate()
public Object getOldContent()
getContent()
, but don't expire the content even if it is marked as
ready to expire. Call this method only when you are unable or unwilling to re-generate the
contents.protected void clearDependencyList()
public void expire()
public DependentCache.Status getStatus()
Status
instance that corresponds to the state of the content© 1998- 2021 Escenic AS