Cache API key doc to reduce traffic to the security index (#59376)

Getting the API key document form the security index is the most time consuing part
of the API Key authentication flow (>60% if index is local and >90% if index is remote).
This traffic is now avoided by caching added with this PR.

Additionally, we add a cache invalidator registry so that clearing of different caches will
be managed in a single place (requires follow-up PRs).
This commit is contained in:
Yang Wang 2020-10-06 21:41:25 +11:00 committed by GitHub
parent c45724079c
commit 9e1f912ccc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 1514 additions and 25 deletions

View file

@ -0,0 +1,34 @@
--
:api: clear-api-key-cache
:request: ClearApiKeyCacheRequest
:response: ClearSecurityCacheResponse
--
[role="xpack"]
[id="{upid}-{api}"]
=== Clear API Key Cache API
[id="{upid}-{api}-request"]
==== Clear API Key Cache Request
A +{request}+ supports clearing API key cache for the given IDs.
It can also clear the entire cache if no ID is specified.
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request]
--------------------------------------------------
<1> the IDs(s) for the API keys to be evicted from the cache
include::../execution.asciidoc[]
[id="{upid}-{api}-response"]
==== Clear API Key Cache Response
The returned +{response}+ allows to retrieve information about where the cache was cleared.
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-response]
--------------------------------------------------
<1> the list of nodes that the cache was cleared on

View file

@ -479,6 +479,7 @@ The Java High Level REST Client supports the following Security APIs:
* <<{upid}-clear-roles-cache>>
* <<{upid}-clear-privileges-cache>>
* <<{upid}-clear-realm-cache>>
* <<{upid}-clear-api-key-cache>>
* <<{upid}-authenticate>>
* <<{upid}-has-privileges>>
* <<{upid}-get-user-privileges>>
@ -511,6 +512,7 @@ include::security/get-privileges.asciidoc[]
include::security/clear-roles-cache.asciidoc[]
include::security/clear-privileges-cache.asciidoc[]
include::security/clear-realm-cache.asciidoc[]
include::security/clear-api-key-cache.asciidoc[]
include::security/authenticate.asciidoc[]
include::security/has-privileges.asciidoc[]
include::security/get-user-privileges.asciidoc[]