Class DataRowStore

java.lang.Object
org.apache.cayenne.access.DataRowStore
All Implemented Interfaces:
Serializable

public class DataRowStore extends Object implements Serializable
A fixed size cache of DataRows keyed by ObjectId.
Since:
1.1
See Also:
  • Field Details

    • SNAPSHOT_EXPIRATION_DEFAULT

      @Deprecated(since="5.0", forRemoval=true) public static final long SNAPSHOT_EXPIRATION_DEFAULT
      Deprecated, for removal: This API element is subject to removal in a future version.
      unused
      See Also:
    • SNAPSHOT_CACHE_SIZE_DEFAULT

      @Deprecated(since="5.0", forRemoval=true) public static final int SNAPSHOT_CACHE_SIZE_DEFAULT
      Deprecated, for removal: This API element is subject to removal in a future version.
      use DefaultDataRowStoreFactory.SNAPSHOT_CACHE_SIZE_DEFAULT
      See Also:
    • name

      protected String name
    • snapshots

      protected final ConcurrentMap<ObjectId,DataRow> snapshots
    • eventManager

      protected transient EventManager eventManager
    • remoteNotificationsHandler

      protected transient EventBridge remoteNotificationsHandler
    • eventSubject

      protected transient EventSubject eventSubject
  • Constructor Details

    • DataRowStore

      public DataRowStore(String name, int maxSize, EventManager eventManager)
      Parameters:
      name - DataRowStore name. Used to identify this DataRowStore in events, etc. Can't be null.
      maxSize - max number of cached snapshots. The cache is LRU, evicting the oldest snapshots past this size.
      eventManager - EventManager that should be used for posting and receiving events.
      Since:
      5.0
  • Method Details

    • setEventBridge

      protected void setEventBridge(EventBridge eventBridge)
    • getEventBridge

      protected EventBridge getEventBridge()
    • size

      public int size()
      Returns current cache size.
    • maximumSize

      public int maximumSize()
      Returns maximum allowed cache size.
    • shutdown

      public void shutdown()
      Shuts down any remote notification connections, and clears internal cache.
    • getName

      public String getName()
      Returns the name of this DataRowStore. Name allows to create EventSubjects for event notifications addressed to or sent from this DataRowStore.
    • setName

      public void setName(String name)
      Sets the name of this DataRowStore. Name allows to create EventSubjects for event notifications addressed to or sent from this DataRowStore.
    • getEventManager

      public EventManager getEventManager()
      Returns an EventManager associated with this DataRowStore.
      Since:
      1.2
    • setEventManager

      public void setEventManager(EventManager eventManager)
      Sets an EventManager associated with this DataRowStore.
      Since:
      1.2
    • getCachedSnapshot

      public DataRow getCachedSnapshot(ObjectId oid)
      Returns cached snapshot or null if no snapshot is currently cached for the given ObjectId.
    • getSnapshotEventSubject

      public EventSubject getSnapshotEventSubject()
      Returns EventSubject used by this SnapshotCache to notify of snapshot changes.
    • clear

      public void clear()
      Expires and removes all stored snapshots without sending any notification events.
    • forgetSnapshot

      public void forgetSnapshot(ObjectId id)
      Evicts a snapshot from cache without generating any SnapshotEvents.
    • processRemoteEvent

      public void processRemoteEvent(SnapshotEvent event)
      Handles remote events received via EventBridge. Performs needed snapshot updates, and then resends the event to local listeners.
    • processSnapshotChanges

      public void processSnapshotChanges(Object postedBy, Map<ObjectId,DataRow> updatedSnapshots, Collection<ObjectId> deletedSnapshotIds, Collection<ObjectId> invalidatedSnapshotIds, Collection<ObjectId> indirectlyModifiedIds)
      Processes changes made to snapshots. Modifies internal cache state, and then sends the event to all listeners. Source of these changes is usually an ObjectStore.