A comprehensive TypeScript client library for interacting with Keycloak's Administration API.
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Cache management provides operations to clear various Keycloak caches, helping administrators refresh cached data and resolve caching-related issues in production environments.
Clear specific types of caches to refresh system state.
/**
* Clear the user cache for the realm
* @returns void
*/
clearUserCache(): Promise<void>;
/**
* Clear the keys cache for the realm
* @returns void
*/
clearKeysCache(): Promise<void>;
/**
* Clear the CRL (Certificate Revocation List) cache for the realm
* @returns void
*/
clearCrlCache(): Promise<void>;
/**
* Clear the realm cache
* @returns void
*/
clearRealmCache(): Promise<void>;import KeycloakAdminClient from "@keycloak/keycloak-admin-client";
const kcAdminClient = new KeycloakAdminClient({
baseUrl: 'http://localhost:8080',
realmName: 'myrealm',
});
await kcAdminClient.auth({
username: 'admin',
password: 'admin',
grantType: 'password',
clientId: 'admin-cli',
});
// Clear user cache (useful after user updates)
await kcAdminClient.cache.clearUserCache();
console.log('User cache cleared');
// Clear keys cache (useful after key rotation)
await kcAdminClient.cache.clearKeysCache();
console.log('Keys cache cleared');
// Clear CRL cache (useful after certificate updates)
await kcAdminClient.cache.clearCrlCache();
console.log('CRL cache cleared');
// Clear realm cache (useful after realm configuration changes)
await kcAdminClient.cache.clearRealmCache();
console.log('Realm cache cleared');
// Clear all caches sequentially
async function clearAllCaches() {
await kcAdminClient.cache.clearUserCache();
await kcAdminClient.cache.clearKeysCache();
await kcAdminClient.cache.clearCrlCache();
await kcAdminClient.cache.clearRealmCache();
console.log('All caches cleared');
}
await clearAllCaches();After Configuration Changes: Clear relevant caches after modifying realm settings, user attributes, or security configurations to ensure changes take effect immediately.
Performance Troubleshooting: Clear caches to resolve performance issues or stale data problems in production environments.
Key Rotation: Clear the keys cache after rotating signing keys or certificates to ensure new keys are immediately available.
User Management: Clear user cache after bulk user operations or identity provider synchronization to refresh user data.
docs