|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> services >> [ cache overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derby.impl.services.cache
Class CachedItem

java.lang.Objectorg.apache.derby.impl.services.cache.CachedItem
- public final class CachedItem
- extends java.lang.Object
A generic class to represent the cache related infomation of a cached object (Cacheable).
The relationship between isValid and settingIdentity can be explain by the
following life cycle of a cached item.
Stage 1 2 3
----------------------
isValid F T T
settingIdentity X T F
In Stage 1, the CachedItem is created but it is invalid and has an entry
that is just a holder object with no identity.
In Stage 2, the identity has been set and the item is being created or
being faulted into the cache.
In Stage 3, the item found in the CachedItem entry
Remove is set if this item is being removed out of existance, not just
being evicted from the cache. When the last referece to it release it from
the cache, it will be removed.
RecentlyUsed is set whenever this item is accessed (via a keep() call).
It is reset by the clockHand as it sweeps around the cache looking for
victims to evict.
MT - must be MT-safe and work with cache manager. Every method that access (set or get) instance variables is synchronized on the cached item object. The following method waits so it should not be called by the cache manager inside a sync block: clean(), waitFor(), create(), remove(). (RESOLVE: need to move these from the cache manager to here)
| Field Summary | |
private org.apache.derby.iapi.services.cache.Cacheable |
entry
The Cacheable object being represented. |
private int |
keepCount
The current keep count on the entry. |
private static int |
RECENTLY_USED
|
private static int |
REMOVE_OK
|
private static int |
REMOVE_REQUESTED
|
private static int |
SETTING_IDENTITY
|
private int |
state
Does entry (the Cacheable) have an identity. |
private static int |
VALID
|
| Constructor Summary | |
CachedItem()
Create a CachedItem in the not valid state. |
|
| Method Summary | |
void |
clean(boolean forRemove)
Clean the cached object |
org.apache.derby.iapi.services.cache.Cacheable |
getEntry()
Get the cached object. |
boolean |
isKept()
Is the cached object kept? |
boolean |
isValid()
Does the cached object have a valid identity. |
void |
keepAfterSearch()
Keep the cached object after a search. |
void |
keepForClean()
|
void |
keepForCreate()
|
void |
notifyRemover()
|
boolean |
recentlyUsed()
Has the cached object been referenced (kept) since the last sweep of the clock hand? |
void |
remove(boolean removeNow)
|
void |
setRemoveState()
Set the state of the to-be removed flag. |
void |
settingIdentityComplete()
|
void |
setUsed(boolean flag)
The clock hand has swept past this entry. |
void |
setValidState(boolean flag)
Set the valid state of the cached object. |
org.apache.derby.iapi.services.cache.Cacheable |
takeOnIdentity(org.apache.derby.iapi.services.cache.CacheManager cm,
org.apache.derby.iapi.services.cache.CacheableFactory holderFactory,
java.lang.Object key,
boolean forCreate,
java.lang.Object createParameter)
Make entry (the Cacheable) take on a new identity. |
boolean |
unkeep()
Unkeep the cached object. |
void |
unkeepForCreate()
|
org.apache.derby.iapi.services.cache.Cacheable |
use()
Allow use of the cacheable entry. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
VALID
private static final int VALID
- See Also:
- Constant Field Values
REMOVE_REQUESTED
private static final int REMOVE_REQUESTED
- See Also:
- Constant Field Values
SETTING_IDENTITY
private static final int SETTING_IDENTITY
- See Also:
- Constant Field Values
REMOVE_OK
private static final int REMOVE_OK
- See Also:
- Constant Field Values
RECENTLY_USED
private static final int RECENTLY_USED
- See Also:
- Constant Field Values
state
private int state
- Does entry (the Cacheable) have an identity.
MT - single thread required : synchronization provided by cache manager.
keepCount
private int keepCount
- The current keep count on the entry.
MT - single thread required : synchronization provided by cache manager.
entry
private org.apache.derby.iapi.services.cache.Cacheable entry
- The Cacheable object being represented.
Mutable - content dynamic
| Constructor Detail |
CachedItem
public CachedItem()
- Create a CachedItem in the not valid state.
| Method Detail |
keepAfterSearch
public void keepAfterSearch()
- Keep the cached object after a search.
keepForCreate
public void keepForCreate()
unkeepForCreate
public void unkeepForCreate()
keepForClean
public void keepForClean()
unkeep
public boolean unkeep()
- Unkeep the cached object.
MT - not synchronized, only modified single threaded by the cache manager
isKept
public final boolean isKept()
- Is the cached object kept?
MT - not synchronized, only accessed single threaded by the cache manager
clean
public void clean(boolean forRemove)
throws org.apache.derby.iapi.error.StandardException
- Clean the cached object
MT -
The wait will not release the lock on the cache manager, so the cache manager should not waitfor clean inside a sync block or the whole cache will freeze
setRemoveState
public void setRemoveState()
- Set the state of the to-be removed flag.
isValid
public final boolean isValid()
- Does the cached object have a valid identity.
setValidState
public void setValidState(boolean flag)
- Set the valid state of the cached object.
getEntry
public org.apache.derby.iapi.services.cache.Cacheable getEntry()
- Get the cached object.
takeOnIdentity
public org.apache.derby.iapi.services.cache.Cacheable takeOnIdentity(org.apache.derby.iapi.services.cache.CacheManager cm, org.apache.derby.iapi.services.cache.CacheableFactory holderFactory, java.lang.Object key, boolean forCreate, java.lang.Object createParameter) throws org.apache.derby.iapi.error.StandardException
- Make entry (the Cacheable) take on a new identity.
settingIdentityComplete
public void settingIdentityComplete()
use
public org.apache.derby.iapi.services.cache.Cacheable use() throws org.apache.derby.iapi.error.StandardException
- Allow use of the cacheable entry.
remove
public void remove(boolean removeNow)
throws org.apache.derby.iapi.error.StandardException
notifyRemover
public void notifyRemover()
setUsed
public void setUsed(boolean flag)
- The clock hand has swept past this entry.
recentlyUsed
public boolean recentlyUsed()
- Has the cached object been referenced (kept) since the last sweep of
the clock hand?
|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> services >> [ cache overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.derby.impl.services.cache.CachedItem