Class JCacheWriterToMapStoreAdapter<K,V>

java.lang.Object
com.loomcache.server.jcache.JCacheWriterToMapStoreAdapter<K,V>
Type Parameters:
K - the key type
V - the value type
All Implemented Interfaces:
MapStore<K,V>

public final class JCacheWriterToMapStoreAdapter<K,V> extends Object implements MapStore<K,V>
Adapter that exposes a JSR-107 CacheWriter (+ optional CacheLoader) as a LoomCache MapStore.

Used by LoomJCache in distributedEnabled mode to funnel all external-store traffic through the underlying DistributedMap's MapStore SPI. This removes the duplicate write-behind scheduler that CacheWriterIntegration used to maintain — there is now a single write-behind pipeline owned by DistributedMap.

Errors from the delegate writer/loader are surfaced as unchecked CacheWriterException/CacheLoaderException, matching the MapStore failure contract; DistributedMap counts them into its write-through/delete-through failure metrics.

  • Constructor Summary

    Constructors
    Constructor
    Description
    JCacheWriterToMapStoreAdapter(@Nullable javax.cache.integration.CacheWriter<? super K, ? super V> writer, @Nullable javax.cache.integration.CacheLoader<K,V> loader)
    Create a MapStore-facing adapter over a JSR-107 writer/loader pair.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    delete(K key)
    Remove a single key from the backing store.
    void
    deleteAll(Collection<? extends K> keys)
    Remove multiple keys.
    @Nullable V
    load(K key)
    Load the value associated with key from the backing store.
    loadAll(Collection<? extends K> keys)
    Load multiple values in one round-trip.
    void
    store(K key, V value)
    Persist a single key/value pair.
    void
    storeAll(Map<? extends K, ? extends V> map)
    Persist multiple key/value pairs.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface MapStore

    loadAllKeys
  • Constructor Details

    • JCacheWriterToMapStoreAdapter

      public JCacheWriterToMapStoreAdapter(@Nullable javax.cache.integration.CacheWriter<? super K, ? super V> writer, @Nullable javax.cache.integration.CacheLoader<K,V> loader)
      Create a MapStore-facing adapter over a JSR-107 writer/loader pair. At least one of the two must be non-null — otherwise there is nothing to bridge.
      Parameters:
      writer - the JSR-107 cache writer, or null if write-through is not used
      loader - the JSR-107 cache loader, or null if read-through is not used
  • Method Details

    • load

      public @Nullable V load(K key)
      Description copied from interface: MapStore
      Load the value associated with key from the backing store.
      Specified by:
      load in interface MapStore<K,V>
      Parameters:
      key - the key to look up (never null)
      Returns:
      the associated value, or null when no value exists
    • loadAll

      public Map<K,V> loadAll(Collection<? extends K> keys)
      Description copied from interface: MapStore
      Load multiple values in one round-trip. Default implementation loops MapStore.load(Object); override for efficiency when the store supports bulk reads.
      Specified by:
      loadAll in interface MapStore<K,V>
      Parameters:
      keys - keys to load (never null; may contain no duplicates)
      Returns:
      a map containing only keys for which a non-null value was loaded
    • store

      public void store(K key, V value)
      Description copied from interface: MapStore
      Persist a single key/value pair.
      Specified by:
      store in interface MapStore<K,V>
      Parameters:
      key - the key (never null)
      value - the value to persist (never null)
    • storeAll

      public void storeAll(Map<? extends K, ? extends V> map)
      Description copied from interface: MapStore
      Persist multiple key/value pairs. Default implementation loops MapStore.store(Object, Object); override for efficiency when the store supports bulk writes.
      Specified by:
      storeAll in interface MapStore<K,V>
      Parameters:
      map - entries to persist (never null)
    • delete

      public void delete(K key)
      Description copied from interface: MapStore
      Remove a single key from the backing store. No-op when the key is absent.
      Specified by:
      delete in interface MapStore<K,V>
      Parameters:
      key - the key to delete (never null)
    • deleteAll

      public void deleteAll(Collection<? extends K> keys)
      Description copied from interface: MapStore
      Remove multiple keys. Default implementation loops MapStore.delete(Object); override for efficiency when the store supports bulk deletes.
      Specified by:
      deleteAll in interface MapStore<K,V>
      Parameters:
      keys - keys to delete (never null)