Class AsyncCacheWriter

  • All Implemented Interfaces:
    Lifecycle, CacheWriter
    Direct Known Subclasses:
    AdvancedAsyncCacheWriter

    public class AsyncCacheWriter
    extends DelegatingCacheWriter
    The AsyncCacheWriter is a delegating CacheStore that buffers changes and writes them asynchronously to the underlying CacheStore.

    Read operations are done synchronously, taking into account the current state of buffered changes.

    There is no provision for exception handling for problems encountered with the underlying store during a write operation, and the exception is just logged.

    When configuring the loader, use the following element:

    <async enabled="true" />

    to define whether cache loader operations are to be asynchronous. If not specified, a cache loader operation is assumed synchronous and this decorator is not applied.

    Write operations affecting same key are now coalesced so that only the final state is actually stored.

    Since:
    4.0
    Author:
    Manik Surtani, Galder ZamarreƱo, Sanne Grinovero, Karsten Blees, Mircea Markus
    • Field Detail

      • stateLock

        protected org.infinispan.persistence.async.BufferLock stateLock
      • state

        protected final java.util.concurrent.atomic.AtomicReference<State> state
    • Constructor Detail

      • AsyncCacheWriter

        public AsyncCacheWriter​(CacheWriter delegate)
    • Method Detail

      • isAvailable

        public boolean isAvailable()
        Returns:
        true if the writer can be connected to, otherwise false
      • bulkUpdate

        public java.util.concurrent.CompletionStage<java.lang.Void> bulkUpdate​(org.reactivestreams.Publisher publisher)
        Description copied from interface: CacheWriter
        Persist all provided entries to the store in chunks, with the size of each chunk determined by the store implementation. If chunking is not supported by the underlying store, then entries are written to the store individually via CacheWriter.write(MarshallableEntry).
        Parameters:
        publisher - a Publisher of MarshallableEntry instances
      • deleteBatch

        public void deleteBatch​(java.lang.Iterable keys)
        Description copied from interface: CacheWriter
        Remove all provided keys from the store in a single batch operation. If this is not supported by the underlying store, then keys are removed from the store individually via CacheWriter.delete(Object).
        Parameters:
        keys - an Iterable of entry Keys to be removed from the store.
      • delete

        public boolean delete​(java.lang.Object key)
        Specified by:
        delete in interface CacheWriter
        Overrides:
        delete in class DelegatingCacheWriter
        Returns:
        true if the entry existed in the persistent store and it was deleted.
      • newState

        protected State newState​(boolean clear,
                                 State next)
      • getState

        public java.util.concurrent.atomic.AtomicReference<State> getState()
      • clearStore

        protected void clearStore()