Record Class CaffeineCacheMapper<K,R,V>

java.lang.Object
java.lang.Record
org.infinispan.container.impl.CaffeineCacheMapper<K,R,V>
Type Parameters:
K - The original cache key type
R - The mapped type
V - The value type of the Caffeine cache which is unchanged
Record Components:
delegate - The actual Caffeine cache to map the key to and from
keyMapper - the way to map the key to a different type
keyUnmapper - the way to unmap the different type to the cache key type
All Implemented Interfaces:
com.github.benmanes.caffeine.cache.Cache<R,V>

public record CaffeineCacheMapper<K,R,V>(com.github.benmanes.caffeine.cache.Cache<K,V> delegate, InjectiveFunction<? super K, ? extends R> keyMapper, InjectiveFunction<? super R, ? extends K> keyUnmapper) extends Record implements com.github.benmanes.caffeine.cache.Cache<R,V>
Mapper class that can be used with caffeine based caches to map a key to a different key as necessary. Note this class does not implement mapping for all optional classes provided from caffeine and is thus why it is in an impl package of core and not in the commons module like KeyMapperMap which does.
  • Constructor Details

    • CaffeineCacheMapper

      public CaffeineCacheMapper(com.github.benmanes.caffeine.cache.Cache<K,V> delegate, InjectiveFunction<? super K, ? extends R> keyMapper, InjectiveFunction<? super R, ? extends K> keyUnmapper)
      Creates an instance of a CaffeineCacheMapper record class.
      Parameters:
      delegate - the value for the delegate record component
      keyMapper - the value for the keyMapper record component
      keyUnmapper - the value for the keyUnmapper record component
  • Method Details

    • getIfPresent

      public @Nullable V getIfPresent(Object key)
      Specified by:
      getIfPresent in interface com.github.benmanes.caffeine.cache.Cache<K,R>
    • get

      public V get(R key, Function<? super R, ? extends V> mappingFunction)
      Specified by:
      get in interface com.github.benmanes.caffeine.cache.Cache<K,R>
    • getAllPresent

      public Map<R, @NonNull V> getAllPresent(Iterable<? extends R> keys)
      Specified by:
      getAllPresent in interface com.github.benmanes.caffeine.cache.Cache<K,R>
    • getAll

      public Map<R, @NonNull V> getAll(Iterable<? extends R> keys, Function<? super Set<? extends R>, ? extends Map<? extends R, ? extends @NonNull V>> mappingFunction)
      Specified by:
      getAll in interface com.github.benmanes.caffeine.cache.Cache<K,R>
    • put

      public void put(R key, @NonNull V value)
      Specified by:
      put in interface com.github.benmanes.caffeine.cache.Cache<K,R>
    • putAll

      public void putAll(Map<? extends R, ? extends @NonNull V> map)
      Specified by:
      putAll in interface com.github.benmanes.caffeine.cache.Cache<K,R>
    • invalidateAll

      public void invalidateAll(Iterable<? extends R> keys)
      Specified by:
      invalidateAll in interface com.github.benmanes.caffeine.cache.Cache<K,R>
    • invalidate

      public void invalidate(Object key)
      Specified by:
      invalidate in interface com.github.benmanes.caffeine.cache.Cache<K,R>
    • invalidateAll

      public void invalidateAll()
      Specified by:
      invalidateAll in interface com.github.benmanes.caffeine.cache.Cache<K,R>
    • estimatedSize

      public long estimatedSize()
      Specified by:
      estimatedSize in interface com.github.benmanes.caffeine.cache.Cache<K,R>
    • stats

      public com.github.benmanes.caffeine.cache.stats.CacheStats stats()
      Specified by:
      stats in interface com.github.benmanes.caffeine.cache.Cache<K,R>
    • cleanUp

      public void cleanUp()
      Specified by:
      cleanUp in interface com.github.benmanes.caffeine.cache.Cache<K,R>
    • policy

      public com.github.benmanes.caffeine.cache.Policy<R, @NonNull V> policy()
      Specified by:
      policy in interface com.github.benmanes.caffeine.cache.Cache<K,R>
    • asMap

      public ConcurrentMap<R, @NonNull V> asMap()
      Specified by:
      asMap in interface com.github.benmanes.caffeine.cache.Cache<K,R>
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • delegate

      public com.github.benmanes.caffeine.cache.Cache<K,V> delegate()
      Returns the value of the delegate record component.
      Returns:
      the value of the delegate record component
    • keyMapper

      public InjectiveFunction<? super K, ? extends R> keyMapper()
      Returns the value of the keyMapper record component.
      Returns:
      the value of the keyMapper record component
    • keyUnmapper

      public InjectiveFunction<? super R, ? extends K> keyUnmapper()
      Returns the value of the keyUnmapper record component.
      Returns:
      the value of the keyUnmapper record component