Requesting persistence
After changing a MemoryStore table, you can call the Table.persist() action to store the changes on disk. Note that you can call persist() only on tables in an on-disk store; you cannot call persist() on tables in correlator-persistent, in-memory, or distributed stores. The correlator automatically persists correlator-persistent stores and their contents at the same time as the rest of the correlator runtime state. Updating a table on disk is an asynchronous action. The MemoryStore enqueues a Finished event to indicate success or failure of this action. The persistent form of the database that contains the tables is transactional. Consequently, if there is a hardware failure either all of the grouped changes are made or none of them are made.
Following is an example of storing a table on disk:
integer id := tbl.persist();
on Finished(id,*,*):f onPersisted(f);
action onPersisted(Finished f) {
if not f.success then { log "Whoops"; die; }
emit "All OK";
When you update a table, the MemoryStore copies only the changes to the on-disk table.
To improve performance, the MemoryStore might group persistence requests from multiple users of a particular store. This means that calling persist() many times in rapid succession is efficient, but this does not affect correctness. If the MemoryStore indicates success, you can be certain that the state at the time of the persist() call (or at the time of some later persist() call) is on disk.
You can call the Store.backup() action to backup the on-disk form of a store while it is open for use by the correlator. This is an asynchronous action that immediately returns an ID. The MemoryStore enqueues a Finished event that contains this ID to indicate success or failure of this action. Be sure to define an event listener for this event.