Class DefaultLazyLoader<S,D>
java.lang.Object
org.keycloak.models.cache.infinispan.DefaultLazyLoader<S,D>
- All Implemented Interfaces:
LazyLoader<S,D>
Default implementation of
LazyLoader that lazily loads and caches data. Data loaded from a source rejected by
the configured cacheability predicate is returned without being cached, so a subsequent invocation attempts to load
the data again. This implementation is thread-safe as cached data is used in instances of
CachedRealm which are shared between multiple threads within a
Keycloak instance.- Author:
- Pedro Igor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget(KeycloakSession session, Supplier<S> sourceSupplier) Returns data from the givensource.
-
Constructor Details
-
DefaultLazyLoader
-
DefaultLazyLoader
Creates a loader that caches loaded data only whencacheableaccepts its source.- Parameters:
loader- function used to load data from a non-null sourcefallback- supplier used when the source is nullcacheable- predicate evaluated against a non-null source after its data has been loaded. If it returnsfalse, the loaded data is returned without being cached and a subsequent invocation attempts to load again. When the source is null, the predicate is not evaluated and the fallback result is stored instead.
-
-
Method Details
-
get
Description copied from interface:LazyLoaderReturns data from the givensource. Data is only fetched fromsourceonce and only if necessary, it is up to implementations to decide the momentum to actually fetch data from source.- Specified by:
getin interfaceLazyLoader<S,D> - Parameters:
session- the sessionsourceSupplier- the source from where data will be fetched.- Returns:
- the data from source
-