keycloak-scim/server_admin/topics/sessions/preloading.adoc
2022-02-08 14:07:16 +01:00

46 lines
1.8 KiB
Text

[[offline-sessions-preloading]]
=== Offline sessions preloading
In addition to {jdgserver_name} caches, offline sessions are stored in a database which means they will be available even after server restart.
By default, the offline sessions are not preloaded from the database into the {jdgserver_name} caches during the server startup, because this
approach has a drawback if there are many offline sessions to be preloaded. It can significantly slow down the server startup time.
Therefore, the offline sessions are lazily fetched from the database by default.
However, {project_name} can be configured to preload the offline sessions from the database into the {jdgserver_name} caches during the server startup.
It can be achieved by setting `preloadOfflineSessionsFromDatabase` property in the `userSessions` SPI to `true`.
The following example shows how to configure offline sessions preloading.
ifeval::["{kc_dist}" == "quarkus"]
[source,bash]
----
bin/kc.[sh|bat] start --spi-user-sessions-infinispan-preload-offline-sessions-from-database=false
----
endif::[]
ifeval::["{kc_dist}" == "wildfly"]
[source,xml]
----
<subsystem xmlns="urn:jboss:domain:keycloak-server:1.1">
...
<spi name="userSessions">
<default-provider>infinispan</default-provider>
<provider name="infinispan" enabled="true">
<properties>
<property name="preloadOfflineSessionsFromDatabase" value="true"/>
</properties>
</provider>
</spi>
...
</subsystem>
----
Equivalent configuration using CLI commands:
[source,bash]
----
/subsystem=keycloak-server/spi=userSessions:add(default-provider=infinispan)
/subsystem=keycloak-server/spi=userSessions/provider=infinispan:add(properties={preloadOfflineSessionsFromDatabase => "true"},enabled=true)
----
endif::[]