Interface RepositoryCache

All Known Implementing Classes:
DefaultRepositoryCache

public interface RepositoryCache
Caches auxiliary data used during repository access like already processed metadata. The data in the cache is meant for exclusive consumption by the repository system and is opaque to the cache implementation. Note: Actual cache implementations must be thread-safe.
See Also:
Restriction:
This interface is not intended to be extended by clients.
Restriction:
This interface is not intended to be implemented by clients.
  • Method Details

    • put

      void put(RepositorySystemSession session, Object key, Object data)
      Puts the specified data into the cache. It is entirely up to the cache implementation how long this data will be kept before being purged, i.e. callers must not make any assumptions about the lifetime of cached data.

      Warning: The cache will directly save the provided reference. If the cached data is mutable, i.e. could be modified after being put into the cache, the caller is responsible for creating a copy of the original data and store the copy in the cache.

      Parameters:
      session - The repository session during which the cache is accessed, must not be null.
      key - The key to use for lookup of the data, must not be null.
      data - The data to store in the cache, may be null.
    • get

      Gets the specified data from the cache.

      Warning: The cache will directly return the saved reference. If the cached data is to be modified after its retrieval, the caller is responsible to create a copy of the returned data and use this instead of the cache record.

      Parameters:
      session - The repository session during which the cache is accessed, must not be null.
      key - The key to use for lookup of the data, must not be null.
      Returns:
      The requested data or null if none was present in the cache.
    • computeIfAbsent

      Retrieve or compute the data associated with the specified key.
      Parameters:
      key - The key for which to retrieve the session data, must not be null.
      supplier - The supplier will compute the new value, must not be null.
      Returns:
      The cache data associated with the key.
      Since:
      2.0.0