Record Class CacheConfig

java.lang.Object
java.lang.Record
org.apache.maven.impl.cache.CacheConfig
Record Components:
scope - the cache retention scope
referenceType - the reference type to use for cache entries (backward compatibility)
keyReferenceType - the reference type to use for keys (null means use referenceType)
valueReferenceType - the reference type to use for values (null means use referenceType)

public record CacheConfig(CacheRetention scope, Cache.ReferenceType referenceType, Cache.ReferenceType keyReferenceType, Cache.ReferenceType valueReferenceType) extends Record
Configuration for cache behavior including scope and reference types. Supports separate reference types for keys and values to enable fine-grained control over eviction behavior and better cache miss analysis.
  • Field Details

    • DEFAULT

      public static final CacheConfig DEFAULT
      Default cache configuration with REQUEST_SCOPED and SOFT reference type.
  • Constructor Details

  • Method Details

    • withScope

      public static CacheConfig withScope(CacheRetention scope)
      Creates a cache configuration with the specified scope and default SOFT reference type.
    • withReferenceType

      public static CacheConfig withReferenceType(Cache.ReferenceType referenceType)
      Creates a cache configuration with the specified reference type and default REQUEST_SCOPED scope.
    • withKeyValueReferenceTypes

      public static CacheConfig withKeyValueReferenceTypes(CacheRetention scope, Cache.ReferenceType keyReferenceType, Cache.ReferenceType valueReferenceType)
      Creates a cache configuration with separate key and value reference types.
    • getEffectiveKeyReferenceType

      public Cache.ReferenceType getEffectiveKeyReferenceType()
      Returns the effective key reference type.
    • getEffectiveValueReferenceType

      public Cache.ReferenceType getEffectiveValueReferenceType()
      Returns the effective value reference type.
    • hasSeparateKeyValueReferenceTypes

      public boolean hasSeparateKeyValueReferenceTypes()
      Returns true if this configuration uses separate reference types for keys and values.
    • 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.
    • scope

      public CacheRetention scope()
      Returns the value of the scope record component.
      Returns:
      the value of the scope record component
    • referenceType

      public Cache.ReferenceType referenceType()
      Returns the value of the referenceType record component.
      Returns:
      the value of the referenceType record component
    • keyReferenceType

      public Cache.ReferenceType keyReferenceType()
      Returns the value of the keyReferenceType record component.
      Returns:
      the value of the keyReferenceType record component
    • valueReferenceType

      public Cache.ReferenceType valueReferenceType()
      Returns the value of the valueReferenceType record component.
      Returns:
      the value of the valueReferenceType record component