public class TransactionalWorkspaceCache extends WorkspaceCache
Normally, each RepositoryCache
instance has for each workspace a single WorkspaceCache instance shared by all sessions.
However, in the event that a session is running within a user transaction, it is possible for the session (or other sessions
that are also participating in the same user transaction) to persist node changes in the document store but to not commit the
transaction. This means that no other transactions should see these persisted-but-not-committed node representations. Thus,
these sessions running within a user transaction cannot share the common WorkspaceCache instance, lest any node representations
persisted-but-not-committed be loaded into the WorkspaceCache (leaking transaction-scoped data outside of the transaction) or
the shared WorkspaceCache instance has already-cached pre-modified representations of the persisted-but-not-committed nodes
(transaction-scoped changes are not visible to the transaction).
Therefore, such sessions running within user transactions need a transactionally-scoped WorkspaceCache instance. Because the ModeShape infrastructure is not set up to handle lots of WorkspaceCache instances, we only want one instance that is actually caching nodes. Therefore, the WorkspaceCache returned from this method will never cache any nodes and will always re-read the nodes from the document store.
WorkspaceCache.NonSystemChangeNotifier, WorkspaceCache.SystemChangeNotifier
LOGGER
Modifier | Constructor and Description |
---|---|
protected |
TransactionalWorkspaceCache(WorkspaceCache sharedWorkspaceCache,
TransactionalWorkspaceCaches txWorkspaceCaches,
Transaction txn) |
Modifier and Type | Method and Description |
---|---|
void |
changed(ChangeSet changes)
Signal that changes have been made to the persisted data.
|
void |
changedWithinTransaction(ChangeSet changes)
Signal that this transaction-specific workspace cache needs to reflect recent changes that have been persisted but not yet
committed.
|
void |
clear()
Clears all changes in the cache.
|
protected void |
evictChangedNodes(ChangeSet changeSet) |
protected void |
internalChangedWithinTransaction(ChangeSet changes) |
protected void |
internalClear() |
checkNotClosed, getAllNodeKeys, getAllNodeKeysAtAndBelow, getChildReference, getNode, getNode, getRepositoryKey, getRootKey, getWorkspaceKey, getWorkspaceName, isEmpty, loadFromDocumentStore, setMinimumStringLengthForBinaryStorage, signalClosed, signalClosing, signalDeleted, toString, unwrap, workspaceCache
protected TransactionalWorkspaceCache(WorkspaceCache sharedWorkspaceCache, TransactionalWorkspaceCaches txWorkspaceCaches, Transaction txn)
public void changed(ChangeSet changes)
WorkspaceCache
changed
in class WorkspaceCache
changes
- the changes to be made; may not be nullpublic void changedWithinTransaction(ChangeSet changes)
changes
- the changes that were persisted but not yet committedTransactions.updateCache(WorkspaceCache, ChangeSet, org.modeshape.jcr.txn.Transactions.Transaction)
public void clear()
NodeCache
clear
in interface NodeCache
clear
in class WorkspaceCache
protected void internalClear()
protected void internalChangedWithinTransaction(ChangeSet changes)
protected void evictChangedNodes(ChangeSet changeSet)
evictChangedNodes
in class WorkspaceCache
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.