2016-02-03 10:20:22 +00:00
|
|
|
<!--
|
|
|
|
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
|
|
|
|
~ and other contributors as indicated by the @author tags.
|
|
|
|
~
|
|
|
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
~ you may not use this file except in compliance with the License.
|
|
|
|
~ You may obtain a copy of the License at
|
|
|
|
~
|
|
|
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
~
|
|
|
|
~ Unless required by applicable law or agreed to in writing, software
|
|
|
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
~ See the License for the specific language governing permissions and
|
|
|
|
~ limitations under the License.
|
|
|
|
-->
|
|
|
|
|
2015-07-17 11:45:43 +00:00
|
|
|
<chapter id="server_cache">
|
|
|
|
<title>Server Cache</title>
|
|
|
|
<para>
|
|
|
|
By default, Keycloak caches realm metadata and users. There are two separate caches, one for realm metadata
|
|
|
|
(realm, application, client, roles, etc...) and one for users. These caches greatly improves the performance of the server.
|
|
|
|
</para>
|
|
|
|
|
2016-03-11 12:00:04 +00:00
|
|
|
<section>
|
|
|
|
<title>Eviction and Expiration</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
By default the user cache contains a maximum of 10000 entries. This is not 10000 users, but 10000 entries in the cache. You can change the maximum
|
|
|
|
number of entries by editing the server configuration <literal>standalone.xml</literal> or <literal>standalone-ha.xml</literal>.
|
|
|
|
Locate the element <literal>cache-container name="keycloak"</literal> and change the eviction policy for the <literal>users</literal> cache. For
|
|
|
|
more information see <ulink url="https://docs.jboss.org/author/display/WFLY10/Infinispan+Subsystem">Infinispan Subsystem documentation</ulink>.
|
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
2015-07-17 11:45:43 +00:00
|
|
|
<section>
|
|
|
|
<title>Disabling Caches</title>
|
|
|
|
<para>
|
2016-03-11 12:00:04 +00:00
|
|
|
To disable the realm or user cache, you must edit the <literal>keycloak-server.json</literal> file
|
|
|
|
in your distribution. Here's what the config looks like initially.
|
2015-07-17 11:45:43 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<programlisting><![CDATA[
|
2016-02-08 21:23:31 +00:00
|
|
|
"userCache": {
|
|
|
|
"infinispan" : {
|
|
|
|
"enabled": true
|
|
|
|
}
|
2015-07-17 11:45:43 +00:00
|
|
|
},
|
|
|
|
|
2016-02-08 21:23:31 +00:00
|
|
|
"realmCache": {
|
|
|
|
"infinispan" : {
|
|
|
|
"enabled": true
|
2015-07-17 11:45:43 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
]]></programlisting>
|
|
|
|
</para>
|
2016-03-11 12:00:04 +00:00
|
|
|
<para>To disable the cache set the enabled field to false for the cache you want to disable:
|
2015-07-17 11:45:43 +00:00
|
|
|
<programlisting><![CDATA[
|
2016-02-08 21:23:31 +00:00
|
|
|
"userCache": {
|
|
|
|
"infinispan" : {
|
|
|
|
"enabled": false
|
|
|
|
}
|
2015-07-17 11:45:43 +00:00
|
|
|
},
|
|
|
|
|
2016-02-08 21:23:31 +00:00
|
|
|
"realmCache": {
|
|
|
|
"infinispan" : {
|
|
|
|
"enabled": false
|
|
|
|
}
|
2015-07-17 11:45:43 +00:00
|
|
|
},
|
|
|
|
]]></programlisting>
|
|
|
|
</para>
|
|
|
|
</section>
|
2016-03-11 12:00:04 +00:00
|
|
|
|
2015-07-17 11:45:43 +00:00
|
|
|
<section>
|
|
|
|
<title>Clear Caches</title>
|
|
|
|
<para>
|
2016-03-11 12:00:04 +00:00
|
|
|
To clear the realm or user cache, go to the Keycloak admin console Realm Settings->Cache Config page. On this page you can clear the realm cache
|
|
|
|
or the user cache. This will clear the caches for all realms and not only the selected realm.
|
2015-07-17 11:45:43 +00:00
|
|
|
</para>
|
|
|
|
</section>
|
2016-02-08 21:23:31 +00:00
|
|
|
</chapter>
|