Class WritebackObjectPersistentStore

java.lang.Object
com.usatiuk.objects.stores.WritebackObjectPersistentStore

@ApplicationScoped public class WritebackObjectPersistentStore extends Object
Asynchronous write cache of objects. Objects are put into a write queue by commitTx, and written to the storage by a separate thread.
  • Constructor Details

    • WritebackObjectPersistentStore

      public WritebackObjectPersistentStore()
  • Method Details

    • asyncFence

      public void asyncFence(long txId, Runnable fn)
      Run a given callback after the transaction with id txId is committed. If the transaction is already committed, the callback is run immediately.
      Parameters:
      txId - transaction id to wait for
      fn - callback to run
    • commitTx

      public Consumer<Runnable> commitTx(Collection<TxRecord.TxObjectRecord<?>> writes)
      Commit a transaction to the persistent store.
      Parameters:
      writes - the transaction manifest
      Returns:
      a function that allows to add a callback to be run after the transaction is committed
    • getSnapshot

      public Snapshot<JObjectKey,JDataVersionedWrapper> getSnapshot()
      Get a snapshot of the persistent store, including the pending writes.
      Returns:
      a snapshot of the store