Spec-Zone.ru › Elasticsearch 8
›Elasticsearch Guide [8.17] ›REST APIs ›Security APIs

Clear cache API

New API reference

For the most up-to-date API details, refer to Security APIs.

Evicts users from the user cache. You can completely clear the cache or evict specific users.

Request

POST /_security/realm/<realms>/_clear_cache

POST /_security/realm/<realms>/_clear_cache?usernames=<usernames>

Description

User credentials are cached in memory on each node to avoid connecting to a remote authentication service or hitting the disk for every incoming request. There are realm settings that you can use to configure the user cache. For more information, see Controlling the user cache.

To evict roles from the role cache, see the Clear roles cache API. To evict privileges from the privilege cache, see the Clear privileges cache API. To evict API keys from the API key cache, see the Clear API key cache API.

Path parameters

<realms>
(Required, string) Comma-separated list of realms to clear. To clear all realms, use *. Does not support other wildcard patterns.
usernames
(Optional, list) A comma-separated list of the users to clear from the cache. If you do not specify this parameter, the API evicts all users from the user cache.

Examples

For example, to evict all users cached by the file realm:

resp = client.security.clear_cached_realms(
    realms="default_file",
)
print(resp)
const response = await client.security.clearCachedRealms({
  realms: "default_file",
});
console.log(response);
POST /_security/realm/default_file/_clear_cache

To evict selected users, specify the usernames parameter:

resp = client.security.clear_cached_realms(
    realms="default_file",
    usernames="rdeniro,alpacino",
)
print(resp)
const response = await client.security.clearCachedRealms({
  realms: "default_file",
  usernames: "rdeniro,alpacino",
});
console.log(response);
POST /_security/realm/default_file/_clear_cache?usernames=rdeniro,alpacino

To clear the caches for multiple realms, specify the realms as a comma-delimited list:

resp = client.security.clear_cached_realms(
    realms="default_file,ldap1",
)
print(resp)
const response = await client.security.clearCachedRealms({
  realms: "default_file,ldap1",
});
console.log(response);
POST /_security/realm/default_file,ldap1/_clear_cache

To clear the caches for all realms, use *.

resp = client.security.clear_cached_realms(
    realms="*",
)
print(resp)
const response = await client.security.clearCachedRealms({
  realms: "*",
});
console.log(response);
POST /_security/realm/*/_clear_cache

© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/security-api-clear-cache.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API