Class AuthSessionCache

java.lang.Object
org.apache.iceberg.rest.auth.AuthSessionCache
All Implemented Interfaces:
AutoCloseable

public class AuthSessionCache extends Object implements AutoCloseable
A cache for AuthSession instances.
  • Constructor Details

    • AuthSessionCache

      public AuthSessionCache(String name, Duration sessionTimeout)
      Creates a new cache with the given session timeout, and with default executor and default ticker for eviction tasks.
      Parameters:
      name - a distinctive name for the cache.
      sessionTimeout - the session timeout. Sessions will become eligible for eviction after this duration of inactivity.
  • Method Details

    • cachedSession

      public <T extends AuthSession> T cachedSession(String key, Function<String,T> loader)
      Returns a cached session for the given key, loading it with the given loader if it is not already cached.
      Type Parameters:
      T - the type of the session.
      Parameters:
      key - the key to use for the session.
      loader - the loader to use to load the session if it is not already cached.
      Returns:
      the cached session.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable