Class AsyncCacheWriter

  • All Implemented Interfaces:
    org.infinispan.commons.api.Lifecycle, CacheWriter
    Direct Known Subclasses:

    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.

    Manik Surtani, Galder ZamarreƱo, Sanne Grinovero, Karsten Blees, Mircea Markus
    • Constructor Detail

      • AsyncCacheWriter

        public AsyncCacheWriter​(CacheWriter delegate)
    • Method Detail

      • start

        public void start()
        Description copied from interface: org.infinispan.commons.api.Lifecycle
        Invoked on component start
        Specified by:
        start in interface org.infinispan.commons.api.Lifecycle
        start in class DelegatingCacheWriter
      • stop

        public void stop()
        Description copied from interface: org.infinispan.commons.api.Lifecycle
        Invoked on component stop
        Specified by:
        stop in interface org.infinispan.commons.api.Lifecycle
        stop in class DelegatingCacheWriter
      • isAvailable

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

        public void writeBatch​(Iterable entries)
        Description copied from interface: CacheWriter
        Persist all provided entries to the store in a single batch update. If this is not supported by the underlying store, then entries are written to the store individually via CacheWriter.write(MarshalledEntry).
        entries - an Iterable of MarshalledEntry to be written to the store.
      • deleteBatch

        public void deleteBatch​(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).
        keys - an Iterable of entry Keys to be removed from the store.
      • newState

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

        protected void clearStore()