|
Protege 3.4 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
S
- the session typeV
- the variable typeR
- the result set typepublic interface Cache<S,V,R>
This interface represents a simple cache mechanism for storing cached values either globally or on a per session basis. This cache mechanism is caching the values (of type R) of a variable (of type V). There are three issues that make the interpretation of this interface rather complex. The first issue is the easier one. When we do a cache lookup and get a non-null value, it is clear that the cache has the result that we want to use. But in some occasions it is important to also know that the cache is complete in the sense that if we get a null value it is also the right answer. To handle this we have created an interval between Cache.startCompleteCache and Cache.finishCompleteCache were all entries added form a complete list of possible values in the cache. We allow for the possibility that values will be invalidated between Cache.startCompleteCache and Cache.finishCompleteCache and even that they will be invalidated after and in that case we keep track of which items may be incomplete and which items are not. The second issue is a bruiser! Transactions!! Oh man!!! This adds a lot of complexity. This means that different sessions might see different values. A session in a transaction may see values that are not visible to other sessions. In addition, the behavior depends on the transaction isolation level. If the level is Read committed or higher, changes made by a session in a transaction are not visible to other sessions until the transaction is committed. This means that we need to distinguish between values read and values written and we need to keep track of who is doing the read or write. If the level is repeatable read or higher then the cache must not return a value for read even if the right value is known because the underlying mechanism needs to be informed of the read. Some usage cases follow. First, in many cases the cache will be a cache of frame values. In this case the caller will hold a weak hash map from Frames to a Cache from Slot-Facet-isTemplate objects to a list of values. Another example is the client who receives Cache updates from the server. The client will receive a cache update from the server only if either the update was made by the client itself or if the session executing the update is not in a transaction. Thus for this case the session type is a boolean indicating if the cache update came from the client itself.
Method Summary | |
---|---|
void |
abortCompleteCache()
|
void |
beginTransaction(S session)
The session has entered a transaction. |
void |
commitTransaction(S session)
A transaction is committed. |
void |
delete(S session)
This notifies the cache that the caller has made deleted the object that this cache represents. |
void |
finishCompleteCache()
The startCompleteCache and the finishCompleteCache are part of a protocol. |
void |
flush()
Try to avoid this. |
int |
getTransactionNesting(S session)
Returns the transaction nesting for a session. |
boolean |
isCacheComplete()
|
boolean |
isDeleted()
This indicates that the cache has entered the deleted state. |
void |
modifyCache(S session,
V var)
This notifies the cache, that the caller has made a change to the value of the var. |
void |
modifyCache(S session,
V var,
R value)
This notifies the cache that the caller has made a change to the value of var and that the caller knows the new value is value. |
CacheResult<R> |
readCache(S session,
V var)
If the variable var is cached then this returns the cached value. |
void |
rollbackTransaction(S session)
A transaction is rolled back. |
void |
startCompleteCache()
The startCompleteCache and the finishCompleteCache are part of a protocol. |
void |
updateCache(S session,
V var)
This call indicates that a read was scheduled but no useful value was retrieved. |
void |
updateCache(S session,
V var,
R value)
The caller has received an update that the new value of var is value. |
Method Detail |
---|
CacheResult<R> readCache(S session, V var)
CacheResult result = cache.readCache(session, var); if (result.isValid()) { return result.getValue(); else { go to the source to find the right value }works and is the recommended approach.
var
- a variable
void updateCache(S session, V var)
session
- the session making the changevar
- value
- void updateCache(S session, V var, R value)
session
- the session making the changevar
- value
- void modifyCache(S session, V var)
session
- the session making the changevar
- the variable being modified.void modifyCache(S session, V var, R value)
session
- the session making the changevar
- the variable being changedvalue
- the new value for the variablevoid delete(S session)
session
- boolean isDeleted()
void flush()
void startCompleteCache()
void finishCompleteCache()
void abortCompleteCache()
boolean isCacheComplete()
void beginTransaction(S session)
session
- void commitTransaction(S session)
session
- void rollbackTransaction(S session)
session
- int getTransactionNesting(S session)
|
Protege 3.4 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |