Class PersistentCacheKey

java.lang.Object
se.liu.ida.hefquin.federation.access.impl.cache.PersistentCacheKey
All Implemented Interfaces:
Serializable

public class PersistentCacheKey extends Object implements Serializable
Immutable cache key for a request sent to a specific federation member. The key is derived from a string-based representation of the request, constructed from the DataRetrievalRequest, the FederationMember, and the PersistentCacheKey.ResponseMode. This representation is hashed using SHA-256 and stored as a 32-byte digest, and equality and hash code are based solely on this digest.
See Also:
  • Field Details

    • requestDigest

      protected final byte[] requestDigest
  • Constructor Details

    • PersistentCacheKey

      public PersistentCacheKey(DataRetrievalRequest req, FederationMember fm, PersistentCacheKey.ResponseMode responseMode)
      Creates a cache key for the given request, federation member, and response mode. The key is computed by constructing a URL representation of the request and hashing it together with the response mode using SHA-256.
      Parameters:
      req - the retrieval request (must not be null)
      fm - the target federation member (must not be null)
      responseMode - the response mode (must not be null)
      Throws:
      IllegalArgumentException - if the request/member combination is unsupported
  • Method Details

    • equals

      public boolean equals(Object obj)
      Compares this key with another object for equality. Two PersistentCacheKey instances are considered equal if and only if the other object is also a PersistentCacheKey and their SHA-256 digests are identical.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns a hash code derived from the SHA-256 digest.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code of this key
    • toString

      public String toString()
      Overrides:
      toString in class Object