WSO2 Identity Server has multiple cache layers that are used to improve performance. The
<IS_HOME>/repository/conf/identity file is used to manage and configure the cache layers. Each cacher layer contains the following attributes:
- name: This is used to build the cache instance and is unique to a JVM. This name is used as the unique identifier when the carbon kernel creates the cache object for a specific cache requirement.
- enable: This is used to enable the cache usage for a specific cache layer. If this parameter is disabled, it means that the feature will not cache the value and depending on the feature, will either persist it in a database or not store it at all at the server level.
- timeout: When a cache entry is added to the cache instance, the start time is recorded and the entry is stored until the time exceeds the timeout value. Once the time reaches the timeout, the cache entry is evicted from the cache. Set this value to
-1to store the cache entry indefinitely.
- capacity: This is the count of the cache entry. Note that this value is not related to the size of the cache.
- isDistributed: This is used to distribute the cache entry over the cluster through Hazelcast. If it is set to false, the cache object is stored only in the local cache. Disabling the distributed cache triggers the cache invalidation notification system, which notifies all other nodes in the cluster to invalide their local caches when one node is updating its local cache.
Let's learn how to configure the cache layers.
Configuring identity application management cache layer
WSO2 Identity Server enables configuring the following identity application management layer attributes.
- AppAuthFrameworkSessionContextCache: The
SessionContextCacheobject contains details about the authenticated user. This must be shared across the nodes in the cluster because this is the unique representation of the authenticated user.
- AuthenticationContextCache: Until the authentication request is successfully authenticated, all authentication information is stored in the
AuthenticationContextCacheobject, which needs to be shared across all nodes in the cluster. Once the user is authenticated successfully, this object will is removed from the cache and the required information is stored in the
- AuthenticationRequestCache: The
AuthenticationRequestCacheobject holds all the required details from the authentication request until the authentication flow is completed by the authentication framework. Note that this is not from the inbound protocol validator level. The Authentication Framework wraps the information to the AuthenticationRequestCache object and stores it in the cache.
- AuthenticationResultCache: The
AuthenticationResultCacheobject holds the authentication result that contains the authenticated user details, claim mappings and other authentication specific results, and stores this information in the cache. Once the user gets authenticated through the authentication framework, it stores this object in the cache and reads the response from the inbound protocol handler once the response is built.
- AppInfoCache: The
AppInfoCacheis a complete representation of the OAuth application information in WSO2 Identity Server. It is unique for the client key and is stored in the cache by wrapping the “OAuthAppDO” object.
- AuthorizationGrantCache: The
AuthorizationGrantCachemanages the user information over tokens. This cache object contains the token, code, and user attributes for the authenticated user with some important information that is needed to access different flows such as id-token building.
- OAuthCache: The
OAuthCacheis a general cache implementation which is not specific to one type of cache. This is used for the following cache entries with its own specific cache key.
- OAuthScopeCache: The
OAuthScopeCacheobject holds scope information such as the name and display name for each scope.
- OAuthSessionDataCache: Once the request is received by the inbound protocol validator, it keeps the requested data by wrapping it in the
OAuthSessionDataCacheobject. This is stored against the
sessionDataKey, which is used to manage the browser state.
The code block below shows an example of the identity application management cache layer.
Configuring identity claim metadata management cache layer
WSO2 Identity Server enables configuring the following identity claim metadata layer attributes:
- LocalClaimCache: This enables caching local cache properties such as mapped attributes.
- ExternalClaimCache: This enables caching external cache properties such as mapped local claim.
- ClaimDialectCache: This enables caching the list of claim dialects.
The code block below shows an example of the identity claim metadata management cache layer.