ASPersistence

The ASPersistence example demonstrates how to implement the external shared-all persistence interface.

With shared-all persistence, all nodes in a space persist their data into a single data store. To use shared-all persistence with ActiveSpaces, you must implement the Persister interface. The implemented persister is then used to store and retrieve data from the data store.

The ASPersistence example provides two example implementations of the Persister interface.

  • The first implementation, SimplePersister, uses an in-memory HashMap as the data store.
  • The second implementation, ASPersister, uses a database as the data store.

The onWrite method of the persister is invoked when data is put into the space.

The onRead method of the persister is invoked when data is read from the data store back into the space.To see data being read back out of the data store, the space needs to be defined with a capacity so that when the capacity is exceeded, the least recently used data in the space is ejected from the space. When data that has been previously ejected from the space is read back into the space, you will see the onRead method of the persister invoked.

The ASPersistence examples does not provide the means to read or write data into the space. Therefore, you should run the ASOperations example program along with the ASPersistence example.