2022-01-17 13:31:34 +00:00
[[offline-sessions-preloading]]
2021-06-17 14:39:30 +00:00
=== Offline sessions preloading
2021-05-31 18:05:04 +00:00
In addition to {jdgserver_name} caches, offline sessions are stored in a database which means they will be available even after server restart.
2022-01-17 13:31:34 +00:00
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.
2021-05-31 18:05:04 +00:00
2022-01-17 13:31:34 +00:00
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`.
2021-05-31 18:05:04 +00:00
2022-01-17 13:31:34 +00:00
The following example shows how to configure offline sessions preloading.
2021-05-31 18:05:04 +00:00
[source,xml]
2021-06-17 14:39:30 +00:00
----
2021-05-31 18:05:04 +00:00
<subsystem xmlns="urn:jboss:domain:keycloak-server:1.1">
...
<spi name="userSessions">
<default-provider>infinispan</default-provider>
<provider name="infinispan" enabled="true">
<properties>
2022-01-17 13:31:34 +00:00
<property name="preloadOfflineSessionsFromDatabase" value="true"/>
2021-05-31 18:05:04 +00:00
</properties>
</provider>
</spi>
...
</subsystem>
----
Equivalent configuration using CLI commands:
[source,bash]
----
/subsystem=keycloak-server/spi=userSessions:add(default-provider=infinispan)
2022-01-17 13:31:34 +00:00
/subsystem=keycloak-server/spi=userSessions/provider=infinispan:add(properties={preloadOfflineSessionsFromDatabase => "true"},enabled=true)
2021-05-31 18:05:04 +00:00
----