Package org.apache.iceberg.rest.auth
Class AuthSessionCache
java.lang.Object
org.apache.iceberg.rest.auth.AuthSessionCache
- All Implemented Interfaces:
AutoCloseable
A cache for
AuthSession
instances.-
Constructor Summary
ConstructorsConstructorDescriptionAuthSessionCache
(String name, Duration sessionTimeout) Creates a new cache with the given session timeout, and with default executor and default ticker for eviction tasks. -
Method Summary
Modifier and TypeMethodDescription<T extends AuthSession>
TcachedSession
(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.void
close()
-
Constructor Details
-
AuthSessionCache
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
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 interfaceAutoCloseable
-