Up: Usage

Storage in database

SemiSpace supports storage of elements in a relation database. The strategy is to perform a poll based persistence on elements having a lifetime larger than a threshold.

To put this another way: It is not useful to persist objects that have a lifetime less than the time it takes the server to re-start. Therefore, no action is necessary for objects that are present only for data exchange. Cache elements and other elements with a long life, on the other hand, can benefit from being stored - which makes them resilient to shutdowns and such.

The persistence plugin does this with a Hibernate configured back end.

Considerations using persistence

Beware of delays: If a long term object is inserted into the space, and the space is terminated with a kill immediately after, the object is lost, as it has not yet been picked up as eligible for storage. This means that your implementation must make allowances for loosing long term objects.

Reinsertions during restart allows you to insert duplicates, or not. Both strategies can give you mismatches. If you insert duplicates, all objects are reintroduced to the space, and a repetitive restart will give the space too many elements of a wrong type. If you do not insert duplicates, a query is performed to see if the object is already present. If it is, it is not re-introduced. This means that if you have more than one object with identical properties, one or more copies are lost.

Connecting persistence module

The SemiSpacePersistentAdmin class is able to exchange the administration module for a SemiSpace module to one that will persist elements after configurable rules.

Examine the semispace-persistence project for details.

Benefit of persistence

The largest benefit is when you do not use Terracotta (as Terracotta is able to persist for you), and need to retain data over restarts - possibly for cache warming purposes.


Up: Usage